shin 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d9d27e5a6711e608d57912c68783183167d6424d
4
- data.tar.gz: d0b2adb079e4842dff7d81d2787d06ff06964060
3
+ metadata.gz: c5a80322f6128bc9801dc492bc9e01e5d3194296
4
+ data.tar.gz: 6b9d061ca672828894c57846f33a25b30a69d427
5
5
  SHA512:
6
- metadata.gz: 58ee596d5d36233940f8da01eed7629e4ea038b21577c84e25689680b16bd92cf736ada444766a697eba9959c4634ed6475bebf25964580469c653056f65eea3
7
- data.tar.gz: e9c7188d3ee63df8cc8dbe3b354d9ae9be74486169750f46b2e47fc78a9db1c13d1a98297a234809e683df8f1eb582c3973b1939289903f71ded510ad20df073
6
+ metadata.gz: afd9b3dc6e3932641c62138b04c1d9e8799ea23b6df414cb5e8f25d1aff92ff48774b679cdc22bbebaa3ef9838440e6ef62e70598a8804d0e72b088d12941074
7
+ data.tar.gz: 2be4cb04f771cddd54fd00a7a914a3b4172439a26a0a7aaa03b83d0447e87e5f4e3fe36eba433789caa151693c249eed6eb29467bb5d9866b46635c508f4498f
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Shin
2
- VERSION = "1.0.1"
2
+ VERSION = "1.0.2"
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.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joakim Nylen