shin 1.2.1 → 1.3.0

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: 51a626fdb87c9fa0bcdc99827121522c2ece1fea
4
- data.tar.gz: 0ac62aa328c46b9c635a745ffcff2102a281cd20
3
+ metadata.gz: ecec717d7cca804f8e00aa1ebf8beda52e5efeed
4
+ data.tar.gz: 7a384eb0d0b040bdaff6da63228f012cb5dfcb30
5
5
  SHA512:
6
- metadata.gz: 0158ed858bad8c54cc0b50f99a19ca2c99405b2a6ae369d5af74cf1ed8ea2f74e9842a14e16f33d074a246eb52064a62abca8076609cd2c5aa12cd0ad2311c07
7
- data.tar.gz: 80e781253b28c6a8d387b1bea1331208db622def3c9e815b9be5c0878b3f132c6d40becd69913bc1d7282492438f70773439e670e352786c2005df60c23678a2
6
+ metadata.gz: 6072eedbb446dbba05c6a2a7a3c9b12bde0262702add8f82e149f400dc4f9c9637b7af16eb2930f2afb67f06342855bb7ab38f276f9ed820224567fb37d9769a
7
+ data.tar.gz: 2e5fb16c83675088f8245581f57e257cd2cb91efe32390b98d6844d80b5c39e5ef2b39485d405765098c4130f38e2c1ab9a292697b31b8bafbcb9b37261fc5ad
@@ -4,61 +4,35 @@ require 'date'
4
4
  module Shin
5
5
  module Data
6
6
  class Previewnetworks
7
-
7
+
8
8
  def new
9
9
  self
10
10
  end
11
-
11
+
12
12
  # Fix these before running
13
13
  def before(params={})
14
14
  raise MissingArgument, "You are missing the argument 'previewnetworks_key' which is required to use this source." unless Shin.get[:previewnetworks_key] != nil
15
-
15
+
16
16
  # Timestamp
17
17
  Shin.get[:previewnetworks_country] ||= "se"
18
-
19
- "http://" + Shin.get[:previewnetworks_country] + ".feed.previewnetworks.com"
20
- end
21
-
22
- # Search (on title)
23
- def search(params={})
24
- url = before()
25
-
26
- # Response
27
- response = Base.get(url + '/v3.1/all/search-2/' + Shin.get[:previewnetworks_key] + '/?' + URI.encode_www_form(params))
28
- raise HTTPError, "The response didn't have a 200 HTTP Code. It had #{response.code}." unless response.code == 200
29
18
 
30
- # Data, it can be multiple reviews for a single movie from different reviewers
31
- doc = Nokogiri::XML(response.body)
32
-
33
- doc.remove_namespaces!
34
- data = []
35
- doc.xpath("//previewnetworks/movies/movie").each do |d|
36
- data << Hash.from_xml(d.to_xml)[:movie]
37
- end
38
-
39
- data.to_hashugar
19
+ "http://cinema.maxplatform.com/api/json/media-feed/" + Shin.get[:previewnetworks_country]
40
20
  end
41
-
42
- # Info
43
- def info(params={})
21
+
22
+ # Search (on imdb)
23
+ def search_imdb(params={})
44
24
  url = before()
45
-
25
+ raise MissingArgument, "You are missing the argument 'imdb_id' which is required to use this source." unless params[:imdb_id] != ""
26
+
46
27
  # Response
47
- response = Base.get(url + '/v3.1/all/' + params[:id].to_s + '/' + Shin.get[:previewnetworks_key] + '/?' + URI.encode_www_form(params))
28
+ response = Base.get(url + '/cinema/all-1/' + Shin.get[:previewnetworks_key] + '/?search_field=imdb_id&search_query=' + params[:imdb_id])
48
29
  raise HTTPError, "The response didn't have a 200 HTTP Code. It had #{response.code}." unless response.code == 200
49
30
 
50
- # Data, it can be multiple reviews for a single movie from different reviewers
51
- doc = Nokogiri::XML(response.body)
52
-
53
- doc.remove_namespaces!
54
- data = {}
55
- doc.xpath("//previewnetworks/movies/movie").each do |d|
56
- data = Hash.from_xml(d.to_xml)[:movie]
57
- end
58
-
31
+ data = Oj.load(response.body) rescue nil
32
+
59
33
  data.to_hashugar
60
34
  end
61
-
35
+
62
36
  end
63
37
  end
64
- end
38
+ end
@@ -0,0 +1,109 @@
1
+ ## Use CMore's mobile api to find movies and tv series
2
+ CMORE_API_URL = "https://middleware2.filmnet.se/dispatch-prod/"
3
+ module Shin
4
+ module Play
5
+ class Cmore
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 'cmore_code' which is required to use this source." unless Shin.get[:cmore_code] != nil
14
+
15
+ return "http://www.cmore." + Shin.get[:cmore_code] + "/", CMORE_API_URL + "capiche.cmore." + Shin.get[:cmore_code] + "/"
16
+ end
17
+
18
+ # Get a list
19
+ def list(list_id)
20
+ domain, api_domain = before()
21
+ country = Shin.get[:cmore_code]
22
+
23
+ # Get list
24
+ response = Base.get(api_domain + 'api/CMA/content/panel/' + list_id + '.json')
25
+ raise HTTPError, "The response didn't have a 200 HTTP Code. It had #{response.code}." unless response.code == 200
26
+
27
+ # Data
28
+ data = Oj.load(response.body) rescue nil
29
+
30
+ # Can't be nil
31
+ if data != nil
32
+ data['results'].to_hashugar
33
+ else
34
+ raise NotValid, "Couldn't parse the JSON"
35
+ end
36
+ end
37
+
38
+ # Show
39
+ def show(params={})
40
+ domain, api_domain = before()
41
+ country = Shin.get[:cmore_code]
42
+
43
+ # Response
44
+ response = Base.get(api_domain + 'serie/' + params[:id] + '.json')
45
+ raise HTTPError, "The response didn't have a 200 HTTP Code. It had #{response.code}." unless response.code == 200
46
+
47
+ # Data
48
+ data = Oj.load(response.body) rescue nil
49
+
50
+ # Can't be nil
51
+ if data != nil
52
+ data.to_hashugar
53
+ else
54
+ raise NotValid, "Couldn't parse the JSON"
55
+ end
56
+
57
+ end
58
+
59
+ # Movie
60
+ def movie(params={})
61
+ domain, api_domain = before()
62
+ country = Shin.get[:cmore_code]
63
+
64
+ # Response
65
+ response = Base.get(api_domain + 'film/' + params[:id] + '.json')
66
+ raise HTTPError, "The response didn't have a 200 HTTP Code. It had #{response.code}." unless response.code == 200
67
+
68
+ # Data
69
+ data = Oj.load(response.body) rescue nil
70
+
71
+ # Can't be nil
72
+ if data != nil
73
+ data.to_hashugar
74
+ else
75
+ raise NotValid, "Couldn't parse the JSON"
76
+ end
77
+
78
+ end
79
+
80
+ # Find
81
+ def find(params={})
82
+ domain, api_domain = before()
83
+ country = Shin.get[:cmore_code]
84
+
85
+ # Response
86
+ response = Base.get(api_domain + 'films/find.json?page_count=50&' + URI.encode_www_form(params))
87
+ raise HTTPError, "The response didn't have a 200 HTTP Code. It had #{response.code}." unless response.code == 200
88
+
89
+ # Data
90
+ data = Oj.load(response.body) rescue nil
91
+
92
+ # Can't be nil
93
+ if data != nil
94
+ data.to_hashugar
95
+ else
96
+ raise NotValid, "Couldn't parse the JSON"
97
+ end
98
+
99
+ end
100
+
101
+
102
+
103
+ # Errors
104
+ class NotValid < StandardError; end
105
+ class MissingArgument < StandardError; end
106
+ class HTTPError < StandardError; end
107
+ end
108
+ end
109
+ end
data/lib/shin/play.rb CHANGED
@@ -12,8 +12,7 @@ require_relative 'play/viasat'
12
12
  #require_relative 'play/plejmo'
13
13
  #require_relative 'play/sfanytime'
14
14
  require_relative 'play/apple'
15
- #require_relative 'play/cmore'
16
- #require_relative 'play/filmnet'
15
+ require_relative 'play/cmore'
17
16
  #require_relative 'play/discshop'
18
17
  require_relative 'play/hbonordic'
19
18
 
@@ -80,6 +79,11 @@ module Shin
80
79
  @hbonordic ||= Hbonordic.new
81
80
  end
82
81
 
82
+ # CMore (NORDIC CONTENT)
83
+ def cmore
84
+ @cmore ||= Cmore.new
85
+ end
86
+
83
87
  # Apple iTunes (WORLDWIDE CONTENT)
84
88
  def apple
85
89
  @apple ||= Apple.new
data/lib/shin/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Shin
2
- VERSION = "1.2.1"
2
+ VERSION = "1.3.0"
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.2.1
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joakim Nylen
@@ -103,6 +103,7 @@ 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/cmore.rb
106
107
  - lib/shin/play/dplay.rb
107
108
  - lib/shin/play/hbonordic.rb
108
109
  - lib/shin/play/oppetarkiv.rb