shin 1.1.0 → 1.2.1

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: a0a5f3a6975b8dea12e153fe170669bb3d00ea1e
4
- data.tar.gz: b4e12a22bebf5a459fe3f78b49742e44aa5b461e
3
+ metadata.gz: 51a626fdb87c9fa0bcdc99827121522c2ece1fea
4
+ data.tar.gz: 0ac62aa328c46b9c635a745ffcff2102a281cd20
5
5
  SHA512:
6
- metadata.gz: 8cfbeb5d249674a31aacf3450d1d6ae17c5c7dc23e87d449032da2301ecae1524cc42d48dffd8c41f4cffac5cbaa968c7ad8d3f5a750b79ea01799248a8728af
7
- data.tar.gz: 8e51485ab8478411f8e244a0eb84977ee4bbbf3cc9eee7dba005aa2ea24c07f0a13aff889415393ba8dfbfdb05f77f78fb1977e972bcd43e692d02389cc9ed26
6
+ metadata.gz: 0158ed858bad8c54cc0b50f99a19ca2c99405b2a6ae369d5af74cf1ed8ea2f74e9842a14e16f33d074a246eb52064a62abca8076609cd2c5aa12cd0ad2311c07
7
+ data.tar.gz: 80e781253b28c6a8d387b1bea1331208db622def3c9e815b9be5c0878b3f132c6d40becd69913bc1d7282492438f70773439e670e352786c2005df60c23678a2
@@ -0,0 +1,101 @@
1
+ ## Dplay have an API but it isn't for public use
2
+ ## - Requires an country gtld
3
+ module Shin
4
+ module Play
5
+ class Dplay
6
+
7
+ def new
8
+ self
9
+ end
10
+
11
+ # Fix these before running
12
+ def before(params={})
13
+ raise MissingArgument, "You are missing the argument 'dplay_code' which is required to use this source." unless Shin.get[:dplay_code] != nil
14
+
15
+ "http://www.dplay." + Shin.get[:dplay_code]
16
+ end
17
+
18
+ # Programs
19
+ def programs(params={})
20
+ domain = before()
21
+
22
+ # Response
23
+ response = Base.get(domain + '/api/v2/ajax/shows?' + URI.encode_www_form(params))
24
+ raise HTTPError, "The response didn't have a 200 HTTP Code. It had #{response.code}." unless response.code == 200
25
+
26
+ # Data
27
+ data = Oj.load(response.body) rescue nil
28
+
29
+ # Multiple
30
+ if data != nil
31
+ data.to_hashugar
32
+ else
33
+ raise NotValid, "Couldn't parse the JSON"
34
+ end
35
+ end
36
+
37
+ # Program
38
+ def program(params={})
39
+ raise MissingArgument, "You are missing the argument 'show_id' which is required to use this source." unless params[:show_id] != ""
40
+ domain = before()
41
+
42
+ # Response
43
+ response = Base.get(domain + '/api/v2/ajax/shows/' + params[:show_id].to_s + '?show_id=' + params[:show_id].to_s)
44
+ raise HTTPError, "The response didn't have a 200 HTTP Code. It had #{response.code}." unless response.code == 200
45
+
46
+ # Data
47
+ data = Oj.load(response.body) rescue nil
48
+
49
+ # Can't be nil
50
+ if data != nil
51
+ data.to_hashugar
52
+ else
53
+ raise NotValid, "Couldn't parse the JSON"
54
+ end
55
+ end
56
+
57
+ # Videos
58
+ def videos(params={})
59
+ domain = before()
60
+
61
+ # Response
62
+ response = Base.get(domain + '/api/v1/ajax/shows/episodes?' + URI.encode_www_form(params))
63
+ raise HTTPError, "The response didn't have a 200 HTTP Code. It had #{response.code}." unless response.code == 200
64
+
65
+ # Data
66
+ data = Oj.load(response.body) rescue nil
67
+
68
+ # Multiple
69
+ if data != nil
70
+ data.to_hashugar
71
+ else
72
+ raise NotValid, "Couldn't parse the JSON"
73
+ end
74
+ end
75
+
76
+ # Module (added recently)
77
+ def module(params={})
78
+ domain = before()
79
+
80
+ # Response
81
+ response = Base.get(domain + '/api/v1/ajax/module?' + URI.encode_www_form(params))
82
+ raise HTTPError, "The response didn't have a 200 HTTP Code. It had #{response.code}." unless response.code == 200
83
+
84
+ # Data
85
+ data = Oj.load(response.body) rescue nil
86
+
87
+ # Multiple
88
+ if data != nil
89
+ data.to_hashugar
90
+ else
91
+ raise NotValid, "Couldn't parse the JSON"
92
+ end
93
+ end
94
+
95
+ # Errors
96
+ class NotValid < StandardError; end
97
+ class MissingArgument < StandardError; end
98
+ class HTTPError < StandardError; end
99
+ end
100
+ end
101
+ end
@@ -11,7 +11,11 @@ module Shin
11
11
  def all(params={})
12
12
 
13
13
  # Response
14
- response = Base.get('https://api-hbon.hbo.clearleap.com/cloffice/client/web/browse/' + params[:id] + '?max=10000&offset=0&language=' + params[:language], {local_host: "188.165.139.194"})
14
+ if params[:offset] != ""
15
+ response = Base.get('https://api-hbon.hbo.clearleap.com/cloffice/client/web/browse/' + params[:id] + '?max=200&offset=' + params[:offset].to_s + '&language=' + params[:language], {local_host: "188.165.139.194"})
16
+ else
17
+ response = Base.get('https://api-hbon.hbo.clearleap.com/cloffice/client/web/browse/' + params[:id] + '?max=10000&offset=0&language=' + params[:language], {local_host: "188.165.139.194"})
18
+ end
15
19
 
16
20
  # They place movies in a "entry" tag somehow
17
21
  response.parsed_response["rss"]["channel"].to_hashugar
@@ -0,0 +1,67 @@
1
+ ## TV2 Sumo have an API but it isn't for public use
2
+ module Shin
3
+ module Play
4
+ class Tv2sumo
5
+
6
+ def new
7
+ self
8
+ end
9
+
10
+ # All tv series
11
+ def series
12
+ # Response
13
+ response = Base.get('https://sumo.tv2.no/rest/categories/90316/shows?sort=alphabetical&size=999')
14
+ raise HTTPError, "The response didn't have a 200 HTTP Code. It had #{response.code}." unless response.code == 200
15
+
16
+ # Data
17
+ data = Oj.load(response.body) rescue nil
18
+
19
+ # Can't be nil
20
+ if data != nil
21
+ data['shows'].to_hashugar
22
+ else
23
+ raise NotValid, "Couldn't parse the JSON"
24
+ end
25
+ end
26
+
27
+ # All movies
28
+ def movies
29
+ # Response
30
+ response = Base.get('https://sumo.tv2.no/rest/categories/90987/movies?sort=alphabetical&size=999')
31
+ raise HTTPError, "The response didn't have a 200 HTTP Code. It had #{response.code}." unless response.code == 200
32
+
33
+ # Data
34
+ data = Oj.load(response.body) rescue nil
35
+
36
+ # Can't be nil
37
+ if data != nil
38
+ data['assets'].to_hashugar
39
+ else
40
+ raise NotValid, "Couldn't parse the JSON"
41
+ end
42
+ end
43
+
44
+ # All children shows
45
+ def junior
46
+ # Response
47
+ response = Base.get('https://sumo.tv2.no/rest/categories/91101/shows?sort=alphabetical&size=999')
48
+ raise HTTPError, "The response didn't have a 200 HTTP Code. It had #{response.code}." unless response.code == 200
49
+
50
+ # Data
51
+ data = Oj.load(response.body) rescue nil
52
+
53
+ # Can't be nil
54
+ if data != nil
55
+ data['shows'].to_hashugar
56
+ else
57
+ raise NotValid, "Couldn't parse the JSON"
58
+ end
59
+ end
60
+
61
+ # Errors
62
+ class NotValid < StandardError; end
63
+ class MissingArgument < StandardError; end
64
+ class HTTPError < StandardError; end
65
+ end
66
+ end
67
+ end
@@ -29,7 +29,7 @@ module Shin
29
29
  if params[:page] != nil
30
30
  id = type + "?pageNumber=" + params[:page].to_s + "&sort=recently_added"
31
31
  elsif params[:season] != nil
32
- id = params[:id] + "?seasonNumber=" + params[:season].to_s
32
+ id = params[:id] + "?seasonNumber=" + params[:season].to_s + "&partial=1&block=2"
33
33
  elsif params[:id] != nil
34
34
  id = params[:id].to_s
35
35
  else
@@ -51,7 +51,12 @@ module Shin
51
51
 
52
52
  # Can't be nil
53
53
  if data != nil
54
- data['_embedded']['viaplay:blocks'].to_hashugar
54
+ # Episodes for a seaosn is in products, not blocks.
55
+ if params[:season] != nil
56
+ data['_embedded']['viaplay:products'].to_hashugar
57
+ else
58
+ data['_embedded']['viaplay:blocks'].to_hashugar
59
+ end
55
60
  else
56
61
  raise NotValid, "Couldn't parse the JSON"
57
62
  end
@@ -102,6 +107,50 @@ module Shin
102
107
  end
103
108
  end
104
109
 
110
+ # Rental movies
111
+ def rental_movies(params={})
112
+ # domain
113
+ domain = before()
114
+ country = Shin.get[:viaplay_country]
115
+
116
+ # Translated shit
117
+ type = "kaikki" if country == "fi"
118
+ type = "alle" if country == "dk" or country == "no"
119
+ type = "samtliga" if country == "se"
120
+
121
+ if params[:page] != nil
122
+ id = type + "?pageNumber=" + params[:page].to_s + "&sort=recently_added"
123
+ elsif params[:id] != nil
124
+ id = params[:id].to_s
125
+ else
126
+ id = type + "?sort=recently_added"
127
+ end
128
+
129
+ # Response
130
+ if country == "fi"
131
+ response = Base.get(domain + 'vuokraamo/' + id)
132
+ elsif country == "dk"
133
+ response = Base.get(domain + 'lejebutik/' + id)
134
+ elsif country == "no"
135
+ response = Base.get(domain + 'leiebutikk/' + id)
136
+ else
137
+ response = Base.get(domain + 'hyrbutik/' + id)
138
+ end
139
+
140
+
141
+ raise HTTPError, "The response didn't have a 200 HTTP Code. It had #{response.code}." unless response.code == 200
142
+
143
+ # Data
144
+ data = Oj.load(response.body) rescue nil
145
+
146
+ # Can't be nil
147
+ if data != nil
148
+ data['_embedded']['viaplay:blocks'].to_hashugar
149
+ else
150
+ raise NotValid, "Couldn't parse the JSON"
151
+ end
152
+ end
153
+
105
154
  # Errors
106
155
  class NotValid < StandardError; end
107
156
  class MissingArgument < StandardError; end
data/lib/shin/play.rb CHANGED
@@ -5,10 +5,10 @@ require_relative 'play/tv4play'
5
5
  require_relative 'play/urplay'
6
6
  require_relative 'play/sbstv'
7
7
  require_relative 'play/viaplay'
8
+ require_relative 'play/dplay'
9
+ require_relative 'play/tv2sumo'
8
10
  #require_relative 'play/netflix'
9
11
  require_relative 'play/viasat'
10
- #require_relative 'play/headweb'
11
- #require_relative 'play/film2home'
12
12
  #require_relative 'play/plejmo'
13
13
  #require_relative 'play/sfanytime'
14
14
  require_relative 'play/apple'
@@ -35,6 +35,11 @@ module Shin
35
35
  @viki ||= Viki.new
36
36
  end
37
37
 
38
+ # DPLAY (SE, NO, DK)
39
+ def dplay
40
+ @dplay ||= Dplay.new
41
+ end
42
+
38
43
  # OPPETARKIV.SE (SWEDISH CONTENT)
39
44
  def oppetarkiv
40
45
  @oppetarkiv ||= Oppetarkiv.new
@@ -45,6 +50,11 @@ module Shin
45
50
  @urplay ||= Urplay.new
46
51
  end
47
52
 
53
+ # TV4PLAY.SE (NORWEGIAN CONTENT)
54
+ def tv2sumo
55
+ @tv2sumo ||= Tv2sumo.new
56
+ end
57
+
48
58
  # TV4PLAY.SE (SWEDISH CONTENT)
49
59
  def tv4play
50
60
  @tv4play ||= Tv4play.new
data/lib/shin/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Shin
2
- VERSION = "1.1.0"
2
+ VERSION = "1.2.1"
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.1.0
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joakim Nylen
@@ -103,10 +103,12 @@ files:
103
103
  - lib/shin/httparty_icebox.rb
104
104
  - lib/shin/play.rb
105
105
  - lib/shin/play/apple.rb
106
+ - lib/shin/play/dplay.rb
106
107
  - lib/shin/play/hbonordic.rb
107
108
  - lib/shin/play/oppetarkiv.rb
108
109
  - lib/shin/play/sbstv.rb
109
110
  - lib/shin/play/svtplay.rb
111
+ - lib/shin/play/tv2sumo.rb
110
112
  - lib/shin/play/tv4play.rb
111
113
  - lib/shin/play/urplay.rb
112
114
  - lib/shin/play/viaplay.rb