imdb_apios 0.1.0

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: d286bf052a812ff6e5fd60a557b012ed06972b6d
4
+ data.tar.gz: 52113b46592d65934a58bbfee7eab9ca459a57d4
5
+ SHA512:
6
+ metadata.gz: 7082f5d635da867ebe63194a607c65a327a751bef3b5debe1d06c2cff90bc31a972767e05bd49ecc66559a17dee925f3f177fec049c55bbb7d3713ba8098a53c
7
+ data.tar.gz: 6886a671cf600c669eeb4f692d852b9cea3f0d8f8cccf46b02dbc1ebc17a26e4d12002e4728bdb4bf83634e6a03bdfaa94aeeb1816b3aaef88fde333aacbc04a
@@ -0,0 +1,256 @@
1
+ q
2
+ results.keys.include?("d")
3
+ results.keys.include?("q")
4
+ results.keys
5
+ results;keys
6
+ results
7
+ q
8
+ url = URI("https://v2.sg.media-imdb.com/suggests/#{first_char}/#{search_url}.json")
9
+ search_url = URI.encode(clean_q)
10
+ clean_q = clean_q.encode!('UTF-8', :invalid => :replace, :undef => :replace)
11
+ url = URI("https://v2.sg.media-imdb.com/suggests/#{first_char}/#{search_url}.json")
12
+ search_url = URI.encode(clean_q)
13
+ clean_q = clean_q.encode('UTF-8', :invalid => :replace, :undef => :replace)
14
+ clean_q.encode('UTF-8', :invalid => :replace, :undef => :replace)
15
+ clean_q.gsub!(/\xC2/n, '')
16
+ clean_q
17
+ URI("https://v2.sg.media-imdb.com/suggests/#{first_char}/#{clean_q..gsub!(/\xC2/n, '')}.json")
18
+ URI("https://v2.sg.media-imdb.com/suggests/#{first_char}/#{clean_q.trim}.json")
19
+ URI("https://v2.sg.media-imdb.com/suggests/#{first_char}/#{clean_q.strip}.json")
20
+ clean_q.strip
21
+ clean_q.to_s
22
+ URI("https://v2.sg.media-imdb.com/suggests/#{first_char}/#{clean_q}.json")
23
+ URI.encode(clean_q)
24
+ URI("https://v2.sg.media-imdb.com/suggests/#{first_char}/#{search_url.to_s}.json")
25
+ URI("https://v2.sg.media-imdb.com/suggests/#{first_char}/#{search_url.url}.json")
26
+ URI("https://v2.sg.media-imdb.com/suggests/#{first_char}/#{search_url}.json")
27
+ URI.encode(clean_q)
28
+ clean_q
29
+ search_url
30
+ q
31
+ URI.encode(clean_q).gsub(/^_/,'').gsub('__','_').gsub(/_$/,'')
32
+ URI.encode(clean_q).gsub(/^_/,'').gsub('__','').gsub(/_$/,'')
33
+ URI.encode(clean_q).gsub(/^_/,'').gsub('__','')
34
+ URI.encode(clean_q).gsub(/^_/,'')
35
+ URI.encode(clean_q)
36
+ search_url
37
+ clean_q
38
+ query
39
+ q
40
+ response.body.gsub(/imdb\$.+\({/,'').gsub(/}\)$/,"}")
41
+ response.body.gsub(/imdb\$.+\({/,'').gsub(/}\)$/,"XXXXXXXXXXXXXXXXXXXXXXX")
42
+ response.body.gsub(/imdb\$.+\({/,'').gsub(/})$/,"XXXXXXXXXXXXXXXXXXXXXXX")
43
+ response.body.gsub(/imdb\$.+\({/,'').gsub(/})$/,"XXXXXXXXXXXXXXXXXXXXXXX"),
44
+ response.body.gsub(/imdb\$.+\({/,'')
45
+ gr = response.body.scan(re)
46
+ gr = response.body.scan(re).first.first
47
+ re = /^imdb\$.+\({{1}}\)/
48
+ response.body.gsub(/imdb\$.+\({/,'')
49
+ response.body.gsub(/imdb\$.+\(/,'')
50
+ gr = response.body.scan(re)
51
+ re = /imdb\${1}/
52
+ gr = response.body.scan(re)
53
+ re = /^imdb\${1}/
54
+ gr = response.body.scan(re)
55
+ gr = response.body.scan(re).first.first
56
+ re = /^imdb\$.+\({1}\)/
57
+ gr = response.body.scan(re).first.first
58
+ re = /^imdb\$.+\({1}(.+)/
59
+ gr = response.body.scan(re).first.first
60
+ re = /^imdb\$.+\({1}(.+)\)$/
61
+ response.body
62
+ gr = response.body.scan(re).first.first
63
+ re = /imdb\$.+\({1}(.+)\)/
64
+ gr = response.body.scan(re).first.first
65
+ gr = response.body.scan(re)
66
+ gr = response.body.scan(re).first
67
+ gr = response.body.scan(re).first.first
68
+ re = /imdb\$.+\({1}(.+)\){1}/
69
+ gr = response.body.scan(re).first.first
70
+ response.body
71
+ q
72
+ JSON.parse gr
73
+ gr = response.body.scan(re).first.first
74
+ response.body.match(re).nil?
75
+ response.body.match(re)
76
+ "response".match(re)
77
+ JSON.parse gr
78
+ JSON.Parse gr
79
+ gr = response.body.scan(re).first.first
80
+ gr = response.body.scan(re).first;first
81
+ gr = response.body.scan(re).first
82
+ gr = response.body.scan(re)
83
+ response.read_body
84
+ JSON.parse gr
85
+ JSON.Parse gr
86
+ JSON::Parse gr
87
+ gr = response.body.scan(re)
88
+ re = /imdb\$.+\({1}(.+)\){1}/
89
+ response.read_body
90
+ response.body
91
+ c
92
+ response.body
93
+ q
94
+ response.body
95
+ response.message
96
+ response
97
+ headers
98
+ q
99
+ response
100
+ q
101
+ response.code
102
+ response
103
+ q
104
+ resource.keys.sort
105
+ resource.keys
106
+ q
107
+ url.path
108
+ url.url
109
+ url
110
+ q
111
+ res.keys()
112
+ res
113
+ q
114
+ res['resource'].keys
115
+ res['resource']
116
+ res.keys
117
+ res.class
118
+ res
119
+ q
120
+ JSON.Parse res
121
+ res.class
122
+ res
123
+ q
124
+ res.read_body
125
+ res
126
+ c
127
+ q
128
+ autho
129
+ authoriz
130
+ q
131
+ string_to_sign
132
+ authoriz
133
+ autho
134
+ q
135
+ string_to_sign
136
+ autho
137
+ authoriz
138
+ q
139
+ string_to_sign
140
+ secret_key
141
+ authoriz
142
+ autho
143
+ q
144
+ string_to_sign
145
+ autho
146
+ authoriz
147
+ q
148
+ c
149
+ string_to_sign
150
+ secret_key
151
+ authoriz
152
+ autho
153
+ c
154
+ headers
155
+ c
156
+ headers
157
+ q
158
+ res
159
+ res = RestClient::Request.execute(method: :get, url: url,timeout: 10, headers: headers)
160
+ res
161
+ RestClient::Request.execute(method: :get, url: url,timeout: 10, headers: headers)
162
+ q
163
+ RestClient::Request.execute(method: :get, url: url,timeout: 10, headers: headers)
164
+ headers
165
+ q
166
+ headers
167
+ RestClient::Request.execute(method: :get, url: url,timeout: 10, headers: headers)
168
+ q
169
+ headers
170
+ url
171
+ RestClient::Request.execute(method: :get, url: url,timeout: 10, headers: headers)
172
+ RestClient::Request.execute(method: :get, url: url,timeout: 10, headers: headers).response
173
+ RestClient::Request.execute(method: :get, url: url,timeout: 10, headers: headers)
174
+ c
175
+ headers
176
+ q
177
+ req.class
178
+ req.head
179
+ req.hea
180
+ req
181
+ req['headers']
182
+ req
183
+ q
184
+ res
185
+ continue
186
+ req.methods
187
+ req['headers']
188
+ req.headers
189
+ req.header
190
+ res.header
191
+ res.ehaders
192
+ res
193
+ q
194
+ headers.keys
195
+ headers
196
+ creds
197
+ headers.keys
198
+ headers
199
+ q
200
+ b64_hmac
201
+ q
202
+ creds['secretAccessKey']
203
+ b64_hmac
204
+ hash
205
+ q
206
+ hash
207
+ q
208
+ creds
209
+ hash.to_s.downcase
210
+ hash
211
+ hash.downcase!
212
+ hash.downcase
213
+ hash.lowercase
214
+ hash.downcase
215
+ hash.down
216
+ hash.class
217
+ hash.downcase
218
+ hash
219
+ b64_hmac
220
+ q
221
+ b64_hmac
222
+ hash
223
+ q
224
+ b64_hmac
225
+ hash
226
+ q
227
+ hash.class
228
+ hash
229
+ b64_hmac
230
+ q
231
+ hash
232
+ q
233
+ hash
234
+ continue
235
+ hash
236
+ q
237
+ hash
238
+ q
239
+ hash
240
+ q
241
+ hash_value
242
+ q
243
+ hash_value
244
+ q
245
+ string_to_sign
246
+ q
247
+ dd = %Q{rr
248
+ q
249
+ string_to_sign
250
+ q
251
+ string_to_sign
252
+ headers_to_sign
253
+ q
254
+ "#{string1}\n#{string2}"
255
+ string2 = 'bar'
256
+ string1 = 'foo'
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
@@ -0,0 +1,3 @@
1
+ SimpleCov.start do
2
+ add_group "lib", "lib"
3
+ end
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.3.4
5
+ before_install: gem install bundler -v 1.16.1
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at raj.deenoo@gmail.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "http://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in imdb_apios.gemspec
6
+ gemspec
@@ -0,0 +1,43 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ imdb_apios (0.1.0)
5
+
6
+ GEM
7
+ remote: http://rubygems.org/
8
+ specs:
9
+ diff-lcs (1.3)
10
+ docile (1.1.5)
11
+ json (2.1.0)
12
+ rake (10.5.0)
13
+ rspec (3.7.0)
14
+ rspec-core (~> 3.7.0)
15
+ rspec-expectations (~> 3.7.0)
16
+ rspec-mocks (~> 3.7.0)
17
+ rspec-core (3.7.1)
18
+ rspec-support (~> 3.7.0)
19
+ rspec-expectations (3.7.0)
20
+ diff-lcs (>= 1.2.0, < 2.0)
21
+ rspec-support (~> 3.7.0)
22
+ rspec-mocks (3.7.0)
23
+ diff-lcs (>= 1.2.0, < 2.0)
24
+ rspec-support (~> 3.7.0)
25
+ rspec-support (3.7.1)
26
+ simplecov (0.15.1)
27
+ docile (~> 1.1.0)
28
+ json (>= 1.8, < 3)
29
+ simplecov-html (~> 0.10.0)
30
+ simplecov-html (0.10.2)
31
+
32
+ PLATFORMS
33
+ ruby
34
+
35
+ DEPENDENCIES
36
+ bundler (~> 1.16)
37
+ imdb_apios!
38
+ rake (~> 10.0)
39
+ rspec (~> 3.0)
40
+ simplecov
41
+
42
+ BUNDLED WITH
43
+ 1.16.1
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 raj
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,137 @@
1
+ # ImdbApios
2
+
3
+ Ruby IMDB client using the IMDB json web service made available for their iOS app.
4
+ Largely inspired by [imdb-pie](https://github.com/richardasaurus/imdb-pie "imdb-pie") in python
5
+
6
+ ## API Terminology
7
+
8
+ - `Title` this can be a movie, tv show, video, documentary etc.
9
+ - `Name` this can be a credit, cast member, any person generally.
10
+
11
+ ## Installation
12
+
13
+ Add this line to your application's Gemfile:
14
+
15
+ ```ruby
16
+ gem 'imdb_apios'
17
+ ```
18
+
19
+ And then execute:
20
+
21
+ ```bash
22
+ $ bundle
23
+ ```
24
+
25
+ Or install it yourself as:
26
+
27
+ ```bash
28
+ $ gem install imdb_apios
29
+ ```
30
+
31
+ Or install it from source:
32
+
33
+ ```bash
34
+ gem 'imdb_apios', :git => 'https://github.com/raj/imdb-apios'
35
+ ```
36
+
37
+ ## Usage
38
+
39
+
40
+ ### Initialise the client
41
+ ```ruby
42
+ require 'imdb_apios'
43
+ @client = ImdbApios::Client.new
44
+ ```
45
+
46
+ ### Available methods
47
+
48
+ NOTE: For each client method, if the resource cannot be found they will raise `StandardError`
49
+
50
+ Example | Description
51
+ --------- | ---------
52
+ `get_title('tt0111161')` | Returns a json containing title information
53
+ `search("The Dark Knight")` | Returns a json of results
54
+ `search("Christian Bale")` | Returns a json of results
55
+ `title_exits('tt0111161')` | Returns True if exists otherwise False
56
+ `get_title_genres('tt0303461')` | Returns a json containing title genres information
57
+ `get_title_credits('tt0303461')` | Returns a json containing title credits information
58
+ `get_title_quotes('tt0303461')` | Returns a json containing title quotes information
59
+ `get_title_ratings('tt0303461')` | Returns a json containing title ratings information
60
+ `get_title_connections('tt0303461')` | Returns a json containing title connections information
61
+ `get_title_similarities('tt0303461')` | Returns a json containing title similarities information
62
+ `get_title_videos('tt0303461')` | Returns a json containing title videos information
63
+ `get_title_news('tt0303461')` | Returns a json containing news
64
+ `get_title_trivia('tt0303461')` | Returns a json containing trivia
65
+ `get_title_soundtracks('tt0303461')` | Returns a json containing soundtracks information
66
+ `get_title_goofs('tt0303461')` | Returns a json containing "goofs" and teaser information
67
+ `get_title_technical('tt0303461')` | Returns a json containing technical information
68
+ `get_title_companies('tt0303461')` | Returns a json containing information about companies related to title
69
+ `get_title_episodes('tt0303461')` | Returns a json containing season and episodes information
70
+ `get_title_episodes_detailed(imdb_id='tt0303461', season=1)` | Returns a json containing detailed season episodes information
71
+ `get_title_plot('tt0111161')` | Returns a json containing title plot information
72
+ `get_title_plot_synopsis('tt0111161')` | Returns a json containing title plot synopsis information
73
+ `get_title_awards('tt0111161')` |Returns a json containing title plot information
74
+ `get_title_releases('tt0111161')` | Returns a json containing releases information
75
+ `get_title_versions('tt0111161')` | Returns a json containing versions information (meaning different versions of this title for different regions, or different versions for DVD vs Cinema)
76
+ `get_title_user_reviews('tt0111161')` | Returns a json containing user review information
77
+ `get_title_metacritic_reviews('tt0111161')` | Returns a json containing metacritic review information
78
+ `get_title_images('tt0111161')` | Returns a json containing title images information
79
+ `get_name('nm0000151')` | Returns a json containing person/name information
80
+ `get_name_filmography('nm0000151')` | Returns a json containing person/name filmography information
81
+ `get_name_images('nm0000032')` | Returns a json containing person/name images information
82
+ `get_name_videos('nm0000032')` | Returns a json containing person/name videos information
83
+ `validate_imdb_id('tt0111161')` | Return false if not valid
84
+ `get_popular_titles()` | Returns a json containing popular titles information
85
+ `get_popular_shows()` | Returns a json containing popular tv shows
86
+ `get_popular_movies()` | Returns a json containing popular movies
87
+
88
+
89
+ ## Requirements
90
+
91
+ 1. Ruby 2
92
+
93
+ ## Running the tests
94
+
95
+ ```bash
96
+ bundle
97
+ rake spec
98
+ ```
99
+
100
+ ## example
101
+
102
+ ```bash
103
+ require 'imdb_apios'
104
+ @client = ImdbApios::Client.new
105
+ @client.search("Katrina Kaif")['d']
106
+
107
+ => [
108
+ {"l"=>"Katrina Kaif", "id"=>"nm1229940", "s"=>"Actress, Zindagi Na Milegi Dobara (2011)", "i"=>["https://images-na.ssl-images-amazon.com/images/M/MV5BMTUwODY3NzA3NF5BMl5BanBnXkFtZTcwNTEzNDg3OA@@._V1_.jpg", 1266, 1767]},
109
+ {"l"=>"Katrina Kroetch", "id"=>"nm6009562", "s"=>"Actress, 13 Reasons Why (2017)", "i"=>["https://images-na.ssl-images-amazon.com/images/M/MV5BYWFkMDU0NzEtM2Y1Zi00ZTZjLWI1NjAtYWEwMDc1ZTI1ZWYzXkEyXkFqcGdeQXVyNDc0NzM1MjE@._V1_.jpg", 3840, 5760]}, {"l"=>"Katrina Kemp", "id"=>"nm4320986", "s"=>"Actress, Faking It (2014-2015)", "i"=>["https://images-na.ssl-images-amazon.com/images/M/MV5BMTg3MzA2ODk3N15BMl5BanBnXkFtZTgwOTc2MzcwMzE@._V1_.jpg", 640, 640]}, {"l"=>"Katrina Kavanaugh", "id"=>"nm7771701", "s"=>"Actress, Longmire (2013)", "i"=>["https://images-na.ssl-images-amazon.com/images/M/MV5BNmVhYzMwYTQtODlhMi00ZGE5LTk2ZGYtZGUyMGUyNTMzYzAwXkEyXkFqcGdeQXVyNjEyODUyNjg@._V1_.jpg", 556, 695]}, {"l"=>"Katrina Kat", "id"=>"nm3698859", "s"=>"Actress, Imprecation (2009)"}, {"l"=>"Kathimerina kai apla", "id"=>"tt7549998", "s"=>"Elsa Poimenidou, Haris Arvanitidis", "y"=>2017, "q"=>"TV series"}, {"l"=>"Horumaika: Tebori Nakayama zuidou no kiroku", "id"=>"tt2066892", "y"=>2005, "q"=>"feature"},
110
+ {"l"=>"Katrina Kane", "id"=>"nm0437365", "s"=>"Editorial Department, The Experiment (2010)"}
111
+ ]
112
+
113
+ ```
114
+
115
+
116
+ ### TODO
117
+
118
+
119
+ - [ ] credentials must not be reload on each request
120
+
121
+
122
+
123
+
124
+ ## Development
125
+
126
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
127
+
128
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
129
+
130
+ ## Contributing
131
+
132
+ Bug reports and pull requests are welcome on GitHub at https://github.com/raj/imdb_apios. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
133
+
134
+ ## License
135
+
136
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
137
+
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "imdb_apios"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,30 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "imdb_apios/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "imdb_apios"
8
+ spec.version = ImdbApios::VERSION
9
+ spec.authors = ["raj"]
10
+ spec.email = ["raj.deenoo@gmail.com"]
11
+
12
+ spec.summary = "ruby IMDB client"
13
+ spec.description = "IMDB client using the IMDB json web service made available for their iOS app."
14
+ spec.homepage = "https://github.com/raj/imdb-apios"
15
+ spec.license = "MIT"
16
+
17
+
18
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
19
+ f.match(%r{^(test|spec|features)/})
20
+ end
21
+ spec.bindir = "exe"
22
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
23
+ spec.require_paths = ["lib"]
24
+
25
+ spec.add_development_dependency "bundler", "~> 1.16"
26
+ spec.add_development_dependency "rake", "~> 10.0"
27
+ spec.add_development_dependency "rspec", "~> 3.0"
28
+ spec.add_development_dependency "simplecov", "~> 0"
29
+
30
+ end
@@ -0,0 +1,11 @@
1
+ require "imdb_apios/version"
2
+ require "imdb_apios/constant"
3
+ require "imdb_apios/client"
4
+ require "imdb_apios/signer"
5
+
6
+ module ImdbApios
7
+ def self.validate_imdb_id imdb_id
8
+ regex = /\A[a-zA-Z]{2}[0-9]{7}\z/
9
+ !regex.match(imdb_id).nil? && imdb_id.length == 9
10
+ end
11
+ end
@@ -0,0 +1,109 @@
1
+ require 'uri'
2
+ require 'net/http'
3
+ require "json"
4
+
5
+
6
+ module ImdbApios
7
+ class Client
8
+
9
+
10
+ def initialize
11
+ ImdbApios::Constant::SIMPLE_GET_ENDPOINTS.each do |key, v|
12
+ define_singleton_method :"#{key}" do |value|
13
+ res = get_resource(v, value)
14
+ return res
15
+ end
16
+ end
17
+ end
18
+
19
+ def title_exists? imdb_id
20
+ return false unless ImdbApios.validate_imdb_id(imdb_id)
21
+ url = URI("http://www.imdb.com/title/#{imdb_id}/")
22
+ http = Net::HTTP.new(url.host, url.port)
23
+ request = Net::HTTP::Get.new(url)
24
+ response = http.request(request)
25
+ return response.code == "200"
26
+ end
27
+
28
+
29
+ def search query
30
+ clean_q = query.gsub(' ',"_").gsub(/[^0-9A-Za-z\-_\.~]/, '').downcase
31
+ first_char = clean_q[0].downcase
32
+ search_url = URI.encode(clean_q)
33
+ url = URI("https://v2.sg.media-imdb.com/suggests/#{first_char}/#{search_url}.json")
34
+ response = get url
35
+ return response
36
+ end
37
+
38
+ def get_popular_titles
39
+ get_resource "/chart/titlemeter"
40
+ end
41
+
42
+ def get_popular_shows
43
+ get_resource "/chart/tvmeter"
44
+ end
45
+
46
+
47
+
48
+
49
+ private
50
+
51
+ def get url
52
+ creds = get_credentials
53
+ params = {}
54
+ headers = ImdbApios::Signer.sign url, creds
55
+
56
+ http = Net::HTTP.new(url.host, url.port)
57
+ http.use_ssl = true
58
+ http.verify_mode = OpenSSL::SSL::VERIFY_NONE
59
+
60
+ request = Net::HTTP::Get.new(url)
61
+ request["content-type"] = 'application/json'
62
+ request["accept-language"] = 'en_US'
63
+ request["x-amz-date"] = headers['X-Amz-Date']
64
+ request["x-amz-security-token"] = headers['X-Amz-Security-Token']
65
+ request["x-amzn-authorization"] = headers['X-Amzn-Authorization']
66
+ request["user-agent"] = 'IMDb/8.3.1 (iPhone9,4; iOS 11.2.1)'
67
+ request.body = ""
68
+
69
+ response = http.request(request)
70
+
71
+ unless response.code == "200"
72
+ raise "StandardError"
73
+ end
74
+ re = /imdb\$.+\({1}(.+)\){1}/ # match suggest query which is not valid json
75
+ if response.read_body.match(re)
76
+ clean_resp = "{" + response.body.gsub(/imdb\$.+\({/,'').gsub(/}\)$/,"}")
77
+ json_response = JSON.parse clean_resp
78
+ else
79
+ json_response = JSON.parse(response.read_body)
80
+ end
81
+
82
+ return json_response
83
+
84
+ end
85
+
86
+
87
+ def get_resource(endpoint, imdb_id="")
88
+ path = endpoint.gsub('{imdb_id}',imdb_id)
89
+ url = URI("https://api.imdbws.com#{path}")
90
+ response = get url
91
+ return response["resource"]
92
+ end
93
+
94
+
95
+ def get_credentials
96
+ url = URI("https://api.imdbws.com/authentication/credentials/temporary/ios82?=")
97
+ http = Net::HTTP.new(url.host, url.port)
98
+ http.use_ssl = true
99
+ request = Net::HTTP::Post.new(url)
100
+ request["content-type"] = 'application/json'
101
+ request.body = {"appKey": ImdbApios::Constant::APP_KEY }.to_json.to_s
102
+ response = http.request(request)
103
+ json_response = JSON.parse(response.read_body)['resource']
104
+ return json_response
105
+ end
106
+
107
+
108
+ end
109
+ end
@@ -0,0 +1,43 @@
1
+
2
+ module ImdbApios
3
+ class Constant
4
+ HOST = 'api.imdbws.com'
5
+ BASE_URI = 'https://' + HOST
6
+ SEARCH_BASE_URI = 'https://v2.sg.media-imdb.com'
7
+ USER_AGENT = 'IMDb/8.3.1 (iPhone9,4; iOS 11.2.1)'
8
+ APP_KEY = '76a6cc20-6073-4290-8a2c-951b4580ae4a'
9
+
10
+
11
+ SIMPLE_GET_ENDPOINTS = {
12
+ 'get_name_images': '/name/{imdb_id}/images',
13
+ 'get_name_videos': '/name/{imdb_id}/videos',
14
+ 'get_title_metacritic_reviews': '/title/{imdb_id}/metacritic',
15
+ 'get_title_user_reviews': '/title/{imdb_id}/userreviews',
16
+ 'get_title_videos': '/title/{imdb_id}/videos',
17
+ 'get_title_images': '/title/{imdb_id}/images',
18
+ 'get_title_companies': '/title/{imdb_id}/companies',
19
+ 'get_title_technical': '/title/{imdb_id}/technical',
20
+ 'get_title_trivia': '/title/{imdb_id}/trivia',
21
+ 'get_title_goofs': '/title/{imdb_id}/goofs',
22
+ 'get_title_soundtracks': '/title/{imdb_id}/soundtracks',
23
+ 'get_title_news': '/title/{imdb_id}/news',
24
+ 'get_title_plot': '/title/{imdb_id}/plot',
25
+ 'get_title_plot_synopsis': '/title/{imdb_id}/plotsynopsis',
26
+ 'get_title_plot_taglines': '/title/{imdb_id}/taglines',
27
+ 'get_title_versions': '/title/{imdb_id}/versions',
28
+ 'get_title_releases': '/title/{imdb_id}/releases',
29
+ 'get_title_quotes': '/title/{imdb_id}/quotes',
30
+ 'get_title_connections': '/title/{imdb_id}/connections',
31
+ 'get_title_genres': '/title/{imdb_id}/genres',
32
+ 'get_title_similarities': '/title/{imdb_id}/similarities',
33
+ 'get_title_awards': '/title/{imdb_id}/awards',
34
+ 'get_title_ratings': '/title/{imdb_id}/ratings',
35
+ 'get_title_credits': '/title/{imdb_id}/fullcredits',
36
+ 'get_name': '/name/{imdb_id}/fulldetails',
37
+ 'get_name_filmography': '/name/{imdb_id}/filmography',
38
+ 'get_title': '/title/{imdb_id}/auxiliary'
39
+ }
40
+
41
+
42
+ end
43
+ end
@@ -0,0 +1,50 @@
1
+ require 'base64'
2
+ require 'digest'
3
+
4
+ module ImdbApios
5
+ class Signer
6
+ def self.sign(url, creds)
7
+ headers = get_auth_headers(url, creds)
8
+ return headers
9
+
10
+ end
11
+
12
+
13
+ private
14
+ def self.get_auth_headers url, creds
15
+ headers = {}
16
+ query = {}
17
+ headers['X-Amz-Date'] = Time.now.strftime("%a, %d %b %Y %H:%M:%S GMT")
18
+ headers['X-Amz-Security-Token'] = creds['sessionToken']
19
+ headers['Host'] = "api.imdbws.com"
20
+ headers_to_sign = headers
21
+
22
+ string_to_sign = <<-EOF
23
+ GET
24
+ #{url.path}
25
+
26
+ host:api.imdbws.com
27
+ x-amz-date:#{headers['X-Amz-Date']}
28
+ x-amz-security-token:#{creds['sessionToken']}
29
+
30
+ EOF
31
+
32
+ secret_key = creds['secretAccessKey']
33
+ access_key_id = creds['accessKeyId']
34
+
35
+ hash = Digest::SHA256.digest string_to_sign.encode('utf-8')
36
+ digest = OpenSSL::Digest.new("sha256")
37
+ b64_hmac = Base64.strict_encode64(OpenSSL::HMAC.digest(digest, secret_key, hash))
38
+ authoriz = "AWS3 AWSAccessKeyId=" + access_key_id
39
+ authoriz = authoriz + ",Algorithm=HmacSHA256,SignedHeaders=Host;X-Amz-Date;X-Amz-Security-Token,Signature=" + b64_hmac
40
+
41
+
42
+ headers['X-Amzn-Authorization'] = authoriz
43
+ headers['User-Agent'] = "IMDb/8.3.1 (iPhone9,4; iOS 11.2.1)"
44
+ return headers
45
+
46
+ end
47
+
48
+
49
+ end
50
+ end
@@ -0,0 +1,3 @@
1
+ module ImdbApios
2
+ VERSION = "0.1.0"
3
+ end
metadata ADDED
@@ -0,0 +1,120 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: imdb_apios
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - raj
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2018-03-05 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.16'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.16'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: simplecov
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: IMDB client using the IMDB json web service made available for their
70
+ iOS app.
71
+ email:
72
+ - raj.deenoo@gmail.com
73
+ executables: []
74
+ extensions: []
75
+ extra_rdoc_files: []
76
+ files:
77
+ - ".byebug_history"
78
+ - ".gitignore"
79
+ - ".rspec"
80
+ - ".simplecov"
81
+ - ".travis.yml"
82
+ - CODE_OF_CONDUCT.md
83
+ - Gemfile
84
+ - Gemfile.lock
85
+ - LICENSE.txt
86
+ - README.md
87
+ - Rakefile
88
+ - bin/console
89
+ - bin/setup
90
+ - imdb_apios.gemspec
91
+ - lib/imdb_apios.rb
92
+ - lib/imdb_apios/client.rb
93
+ - lib/imdb_apios/constant.rb
94
+ - lib/imdb_apios/signer.rb
95
+ - lib/imdb_apios/version.rb
96
+ homepage: https://github.com/raj/imdb-apios
97
+ licenses:
98
+ - MIT
99
+ metadata: {}
100
+ post_install_message:
101
+ rdoc_options: []
102
+ require_paths:
103
+ - lib
104
+ required_ruby_version: !ruby/object:Gem::Requirement
105
+ requirements:
106
+ - - ">="
107
+ - !ruby/object:Gem::Version
108
+ version: '0'
109
+ required_rubygems_version: !ruby/object:Gem::Requirement
110
+ requirements:
111
+ - - ">="
112
+ - !ruby/object:Gem::Version
113
+ version: '0'
114
+ requirements: []
115
+ rubyforge_project:
116
+ rubygems_version: 2.6.14
117
+ signing_key:
118
+ specification_version: 4
119
+ summary: ruby IMDB client
120
+ test_files: []