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 +4 -4
- data/lib/shin/play/svtplay.rb +22 -16
- data/lib/shin/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f88b245d536e37f994db96a834b9f90c688e939c
|
|
4
|
+
data.tar.gz: 2dfb8fc4d27962af60c827275cc8fda74052bb8a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 824c39e0be5f1d42a1f5cb152e71458cabe8ab2d66957d8a2e73fc791704eb39a3dd0b5845b65ca77229ab91a3b853f350a6244e2851e07642c02dfc3b504126
|
|
7
|
+
data.tar.gz: 9235d0207ee2a5bbac1bfe3e208f66c8d53e73a82615290aeef67a637d30bfa0820e41f1b4bbaeb0da465a74ba7e19131b6f21b8ae480f97be2d0f12e53b415a
|
data/lib/shin/play/svtplay.rb
CHANGED
|
@@ -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
|
-
|
|
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("
|
|
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
|
-
|
|
157
|
-
|
|
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