shin 1.0.3 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 659233c01df303c6bd476c1158172857a04093de
4
- data.tar.gz: 72f02861b885bcfc1e5aadb8106f5a53f3e94a10
3
+ metadata.gz: f88b245d536e37f994db96a834b9f90c688e939c
4
+ data.tar.gz: 2dfb8fc4d27962af60c827275cc8fda74052bb8a
5
5
  SHA512:
6
- metadata.gz: 8558a6d8dcc4415d8f39fc63b576769c31ff2d30f52e3bc755f0e61fcb1d0147bba6b88af26cb64f5a6bc89ae32d8289bdfb59c0ba31ff9c2e548a21e463a361
7
- data.tar.gz: ccee6a02fa66ba02b441f40eaea2d58f49f1dbda9360a9fe67bbad4826c2b73783a7d4c03af6502d8bb0f25a3532960f27b898863a61c18eb5ddba1ce6e26acf
6
+ metadata.gz: 824c39e0be5f1d42a1f5cb152e71458cabe8ab2d66957d8a2e73fc791704eb39a3dd0b5845b65ca77229ab91a3b853f350a6244e2851e07642c02dfc3b504126
7
+ data.tar.gz: 9235d0207ee2a5bbac1bfe3e208f66c8d53e73a82615290aeef67a637d30bfa0820e41f1b4bbaeb0da465a74ba7e19131b6f21b8ae480f97be2d0f12e53b415a
@@ -22,10 +22,11 @@ module Shin
22
22
  # Can't be nil
23
23
  if @main_noko != nil
24
24
  # Title
25
- @image = @main_noko.css('img.play_title-page-trailer__image')[0]['src'].strip rescue nil
26
-
25
+ @image = URI(@main_noko.css('img.play_title-page-trailer__image')[0]['src'].strip) rescue nil
26
+ @image.scheme = 'http' if !@image.nil?
27
+
27
28
  # Data
28
- @array = {image: @image, episodes: []}
29
+ @array = {image: @image.to_s, episodes: []}
29
30
 
30
31
  # Episodes
31
32
  @main_noko.css('div#play_js-tabpanel-more-episodes > ul > li').map do |e|
@@ -34,9 +35,10 @@ module Shin
34
35
  @desc = e.css('p.play_vertical-list__description-text').text.strip rescue nil
35
36
  @season = e.css('h2.play_vertical-list__header > a').text.strip[/S.song\s+(\d+)/, 1].to_i rescue nil
36
37
  @episode = e.css('h2.play_vertical-list__header > a').text.strip[/Avsnitt\s+(\d+)/, 1].to_i rescue nil
37
- @image = e.css('img.play_vertical-list__image')[0]['src'].gsub("ALTERNATES/small", "ALTERNATES/extralarge") rescue nil
38
-
39
- @array[:episodes] << {id: @video_id, image: @image, season: @season, episode: @episode, subtitle: @subtitle, url: @url, description: @desc}
38
+ @image = URI(e.css('img.play_vertical-list__image')[0]['src'].gsub("ALTERNATES/small", "ALTERNATES/extralarge")) rescue nil
39
+ @image.scheme = 'http' if !@image.nil?
40
+
41
+ @array[:episodes] << {id: @video_id, image: @image.to_s, season: @season, episode: @episode, subtitle: @subtitle, url: @url, description: @desc}
40
42
  end
41
43
  else
42
44
  raise NotValid, "Nokogiri failed to parse the HTML."
@@ -70,8 +72,9 @@ module Shin
70
72
  @desc = e.css('a')[0]['title'] rescue nil
71
73
  @season = e['data-season'].to_i rescue nil
72
74
  @episode = e['data-title'][/Avsnitt\s+(\d+)/, 1].to_i rescue nil
73
- @image = e.css('a img')[0]['src'].gsub("ALTERNATES/small", "ALTERNATES/extralarge") rescue nil
74
-
75
+ @image = URI(e.css('a img')[0]['src'].gsub("ALTERNATES/small", "ALTERNATES/extralarge")) rescue nil
76
+ @image.scheme = 'http' if !@image.nil?
77
+
75
78
  # Parse published_to
76
79
  if pto = e['data-available']
77
80
  # Days
@@ -90,7 +93,7 @@ module Shin
90
93
  @subtitle = e['data-title'].gsub(@title + " - ", '').strip
91
94
  end
92
95
 
93
- @array[:results] << {id: @video_id, image: @image, season: @season, episode: @episode, subtitle: @subtitle, url: @url, description: @desc, published_to: @published_to}
96
+ @array[:results] << {id: @video_id, image: @image.to_s, season: @season, episode: @episode, subtitle: @subtitle, url: @url, description: @desc, published_to: @published_to}
94
97
  end
95
98
  else
96
99
  raise NotValid, "Nokogiri failed to parse the HTML."
@@ -138,7 +141,7 @@ module Shin
138
141
  # Cant be nil
139
142
  if @main_noko != nil
140
143
  # Title
141
- @title = @main_noko.css("h1.play_video-area-aside__title")[0].text.strip
144
+ @title = @main_noko.css("a.play_video-area-aside__linked-title")[0].text.strip
142
145
 
143
146
  # Subtitle data
144
147
  submeta = @main_noko.css("h2.play_video-area-aside__sub-title")[0].text.strip.gsub("\n", ' ').squeeze(' ') rescue nil
@@ -153,15 +156,18 @@ module Shin
153
156
  # Player data
154
157
  playerdata = @main_noko.css("a.play_js-svtplayer")[0]
155
158
  @published_on = Time.at(playerdata['data-popularity-publish-date'].to_i/1000) rescue nil
156
- if playerdata['data-expires-timestamp'] != nil
157
- @published_to = Time.at(playerdata['data-expires-timestamp'].to_i/1000) rescue nil
159
+ pub_to = @main_noko.css('p.play_video-area-aside__info-text').last.text.strip rescue nil
160
+
161
+ if !pub_to.nil? and dayz = pub_to[/(\d+) dag/, 1].to_i
162
+ @published_to = Time.parse("23:59", (Date.today + dayz).to_time) rescue nil
158
163
  else
159
164
  @published_to = nil
160
165
  end
161
166
  @url = playerdata['data-popularity-url'] rescue nil
162
167
  @length = (playerdata['data-length'].to_i)/60 rescue nil
163
- @image = @main_noko.css('meta[property="og:image"]')[0]['content'].gsub("ALTERNATES/medium", "ALTERNATES/extralarge") rescue nil
164
-
168
+ @image = URI(@main_noko.css('meta[property="og:image"]')[0]['content'].gsub("ALTERNATES/medium", "ALTERNATES/extralarge")) rescue nil
169
+ @image.scheme = 'http' if !@image.nil?
170
+
165
171
  # Add subtitle from playerdata
166
172
  if submeta != nil and @episode > 0
167
173
  @subtitle = playerdata['data-title'].gsub(@title + " - ", '').gsub("Avsnitt " + @episode.to_s + ':', '').gsub("Avsnitt " + @episode.to_s, '').strip
@@ -172,7 +178,7 @@ module Shin
172
178
  @subtitle = nil if @subtitle == ""
173
179
  end
174
180
 
175
- { id: params[:id].to_i, title: @title, image: @image, season: @season, episode: @episode, subtitle: @subtitle, length: @length, published_on: @published_on, published_to: @published_to, url: @url, description: @desc }.to_hashugar
181
+ { id: params[:id].to_i, title: @title, image: @image.to_s, season: @season, episode: @episode, subtitle: @subtitle, length: @length, published_on: @published_on, published_to: @published_to, url: @url, description: @desc }.to_hashugar
176
182
  else
177
183
  raise NotValid, "Nokogiri failed to parse the HTML."
178
184
  end
@@ -184,4 +190,4 @@ module Shin
184
190
  class HTTPError < StandardError; end
185
191
  end
186
192
  end
187
- end
193
+ end
data/lib/shin/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Shin
2
- VERSION = "1.0.3"
2
+ VERSION = "1.0.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shin
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joakim Nylen