shin 1.0.1 → 1.0.2
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 +35 -0
- 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: c5a80322f6128bc9801dc492bc9e01e5d3194296
|
4
|
+
data.tar.gz: 6b9d061ca672828894c57846f33a25b30a69d427
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: afd9b3dc6e3932641c62138b04c1d9e8799ea23b6df414cb5e8f25d1aff92ff48774b679cdc22bbebaa3ef9838440e6ef62e70598a8804d0e72b088d12941074
|
7
|
+
data.tar.gz: 2be4cb04f771cddd54fd00a7a914a3b4172439a26a0a7aaa03b83d0447e87e5f4e3fe36eba433789caa151693c249eed6eb29467bb5d9866b46635c508f4498f
|
data/lib/shin/play/svtplay.rb
CHANGED
@@ -10,6 +10,41 @@ module Shin
|
|
10
10
|
self
|
11
11
|
end
|
12
12
|
|
13
|
+
# Get a show
|
14
|
+
def show(params={})
|
15
|
+
# Response
|
16
|
+
response = Base.get('http://www.svtplay.se/' + params[:slug].to_s + '?' + URI.encode_www_form(params))
|
17
|
+
raise HTTPError, "The response didn't have a 200 HTTP Code. It had #{response.code}." unless response.code == 200
|
18
|
+
|
19
|
+
# Nokogiri parse
|
20
|
+
@main_noko = Nokogiri::HTML response.body rescue nil
|
21
|
+
|
22
|
+
# Can't be nil
|
23
|
+
if @main_noko != nil
|
24
|
+
# Title
|
25
|
+
@image = @main_noko.css('img.play_title-page-trailer__image')[0]['src'].strip rescue nil
|
26
|
+
|
27
|
+
# Data
|
28
|
+
@array = {image: @image, episodes: []}
|
29
|
+
|
30
|
+
# Episodes
|
31
|
+
@main_noko.css('div#play_js-tabpanel-more-episodes > ul > li').map do |e|
|
32
|
+
@video_id = e.css('a.play_vertical-list__video-element-thumbnail')[0]['href'][/\/video\/(\d+)\//, 1].to_i rescue nil
|
33
|
+
@url = "http://www.svtplay.se" + e.css('h2.play_vertical-list__header a')[0]['href'] rescue nil
|
34
|
+
@desc = e.css('p.play_vertical-list__description-text').text.strip rescue nil
|
35
|
+
@season = e.css('h2.play_vertical-list__header > a').text.strip[/S.song\s+(\d+)/, 1].to_i rescue nil
|
36
|
+
@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}
|
40
|
+
end
|
41
|
+
else
|
42
|
+
raise NotValid, "Nokogiri failed to parse the HTML."
|
43
|
+
end
|
44
|
+
|
45
|
+
@array.to_hashugar
|
46
|
+
end
|
47
|
+
|
13
48
|
# Get episodes for a slug
|
14
49
|
def episodes(params={})
|
15
50
|
# Response
|
data/lib/shin/version.rb
CHANGED