tmdb-api 0.0.5 → 0.0.6
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/.rspec +1 -1
- data/.ruby-version +1 -0
- data/.travis.yml +1 -0
- data/README.md +82 -188
- data/lib/tmdb-api/base.rb +2 -3
- data/lib/tmdb-api/changes.rb +29 -4
- data/lib/tmdb-api/movie.rb +2 -3
- data/lib/tmdb-api/version.rb +1 -1
- data/spec/fixtures/movie/credits.json +681 -0
- data/spec/tmdb-api/change_spec.rb +5 -8
- data/spec/tmdb-api/movie_spec.rb +7 -7
- data/tmdb-api.gemspec +3 -3
- metadata +31 -32
- data/spec/fixtures/movie/cast.json +0 -253
- data/spec/fixtures/movie/crew.json +0 -103
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7bd9362cdbe5d931bfd354ea7e22fd7c23d5ee68
|
4
|
+
data.tar.gz: 1c35adffd61d54740fb67258d9eabf3c955d4fff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d4e8791e638143afc121582290b1c1016f0020333ef74fe07bffbc7479e7ab5755f5a8e9e387a03d006a08e86bcc1572fe8c9bf8b2a8aa309f81c37a666fe095
|
7
|
+
data.tar.gz: 5d664181bd57667b2ffac0be8c3406b116c2b025c96ff6741f65f4b25720a337945c67c91e99ca37bb24da693aa43ac131866ad6b9f5072df0c6981fad8bc05e
|
data/.rspec
CHANGED
@@ -1 +1 @@
|
|
1
|
-
--colour
|
1
|
+
--colour
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.1.0
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -31,8 +31,8 @@ TMDb.api_key = '56565958363476674e5e63643c787867'
|
|
31
31
|
|
32
32
|
Also it's possible set the API in the `TMDB_API_KEY` environment variable:
|
33
33
|
|
34
|
-
```
|
35
|
-
export TMDB_API_KEY='56565958363476674e5e63643c787867'
|
34
|
+
```sh
|
35
|
+
$ export TMDB_API_KEY='56565958363476674e5e63643c787867'
|
36
36
|
```
|
37
37
|
|
38
38
|
## Usage
|
@@ -42,133 +42,82 @@ Get the basic movie information for a specific movie id.
|
|
42
42
|
|
43
43
|
```ruby
|
44
44
|
TMDB::Movie.find(24)
|
45
|
-
# => #<TMDb::Movie:0x007f99 @id=24, @title="Kill Bill: Vol. 1", @imdb_id="tt0266697" ... >
|
46
45
|
|
47
46
|
TMDB::Movie.find(603, language: 'pt')
|
48
|
-
# => #<TMDb::Movie:0x007f99 @id=603, @title="The Matrix", @imdb_id="tt0133093" ... >
|
49
47
|
```
|
50
48
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
49
|
+
Optional parameters:
|
50
|
+
|
51
|
+
- `language` - ISO 639-1 code.
|
52
|
+
|
53
|
+
The available attributes are: _id_, _adult_, _backdrop_path_, _belongs_to_collection_,
|
54
|
+
_budget_, _genres_, _homepage_, _imdb_id_, _original_title_, _overview_,
|
55
|
+
_popularity_, _poster_path_, _production_companies_, _runtime_,
|
56
|
+
_production_countries_, _release_date_, _revenue_, _spoken_languages_, _status_,
|
57
|
+
_tagline_, _title_, _vote_average_, _vote_count_.
|
58
|
+
|
56
59
|
|
57
60
|
### Search movies
|
58
61
|
Search for movies by title.
|
59
62
|
|
60
63
|
```ruby
|
61
64
|
TMDb::Movie.search('Forrest')
|
62
|
-
# => [#<TMDb::Movie:0x007f92 @id=13, @title="Forrest Gump", ...>,
|
63
|
-
# #<TMDb::Movie:0x007f93 @id=711, @title="Finding Forrester", ...>,
|
64
|
-
# #<TMDb::Movie:0x007f94 ... >, ...]
|
65
65
|
|
66
66
|
TMDb::Movie.search('wall e', year: 2003)
|
67
|
-
# => [#<TMDb::Movie:0x007f92 @id=10681, @original_title="WALL·E", ...>]
|
68
67
|
```
|
69
|
-
|
70
|
-
|
68
|
+
|
69
|
+
Optional parameters:
|
70
|
+
|
71
|
+
- `page` - Minimum 1, maximum 1000.
|
72
|
+
- `language` - ISO 639-1 code.
|
73
|
+
- `include_adult` - Toggle the inclusion of adult titles. Expected value is:
|
74
|
+
_true_ or _false_.
|
75
|
+
- `year` - Filter the results release dates to matches that include this value.
|
76
|
+
- `primary_release_year` - Filter the results so that only the primary release
|
77
|
+
dates have this value.
|
78
|
+
- `search_type` - By default, the search type is 'phrase'. This is almost
|
79
|
+
guaranteed the option you will want. It's a great all purpose search type and by
|
80
|
+
far the most tuned for every day querying. For those wanting more of an
|
81
|
+
"autocomplete" type search, set this option to 'ngram'.
|
82
|
+
|
71
83
|
|
72
84
|
### Alternative titles
|
73
85
|
Get the alternative titles for a specific movie id.
|
74
86
|
|
75
87
|
```ruby
|
76
88
|
TMDB::Movie.alternative_titles(598)
|
77
|
-
|
78
|
-
|
79
|
-
# {"iso_3166_1"=>"BR", "title"=>"Cidade de Deus"},
|
80
|
-
# {"iso_3166_1"=>"FR", "title"=>"La cité de Dieu"},
|
81
|
-
# {"iso_3166_1"=>"DE", "title"=>"City of God"},
|
82
|
-
# {"iso_3166_1"=>"CN", "title"=>"上帝之城"},
|
83
|
-
# {"iso_3166_1"=>"HK", "title"=>"无主之城"},
|
84
|
-
# {"iso_3166_1"=>"US", "title"=>"City of God"},
|
85
|
-
# {"iso_3166_1"=>"TW", "title"=>"無法無天"}]
|
86
|
-
|
87
|
-
movie.alternative_titles(country: 'br')
|
88
|
-
# => [{"iso_3166_1"=>"BR", "title"=>"Cidade de Deus"}]
|
89
|
+
|
90
|
+
TMDB::Movie.alternative_titles(598, country: 'br')
|
89
91
|
```
|
90
92
|
|
93
|
+
Optional parameters:
|
94
|
+
|
95
|
+
- `country` - ISO 3166-1 code.
|
96
|
+
|
91
97
|
### Cast
|
92
98
|
Get the cast for a specific movie id.
|
93
99
|
|
94
100
|
```ruby
|
95
101
|
TMDb::Movie.cast(550)
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
# "name"=>"Edward Norton",
|
100
|
-
# "character"=>"The Narrator",
|
101
|
-
# "order"=>0,
|
102
|
-
# "cast_id"=>4,
|
103
|
-
# "profile_path"=>"/588Hrov6wwM9WcU88nJHlw2iufN.jpg"
|
104
|
-
# },
|
105
|
-
# {
|
106
|
-
# "id"=>287,
|
107
|
-
# "name"=>"Brad Pitt",
|
108
|
-
# "character"=>"Tyler Durden",
|
109
|
-
# "order"=>1,
|
110
|
-
# "cast_id"=>5,
|
111
|
-
# "profile_path"=>"/kc3M04QQAuZ9woUvH3Ju5T7ZqG5.jpg"
|
112
|
-
# },
|
113
|
-
# {
|
114
|
-
# ...
|
115
|
-
# }
|
116
|
-
# ]
|
102
|
+
|
103
|
+
TMDb::Movie.cast(550, language: 'pt')
|
104
|
+
```
|
117
105
|
|
118
106
|
### Crew
|
119
107
|
Get the crew for a specific movie id.
|
120
108
|
|
121
109
|
```ruby
|
122
110
|
TMDb::Movie.crew(550)
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
# "profile_path"=>nil
|
130
|
-
# },
|
131
|
-
# {
|
132
|
-
# "id"=>7474,
|
133
|
-
# "name"=>"Ross Grayson Bell",
|
134
|
-
# "department"=>"Production",
|
135
|
-
# "job"=>"Producer",
|
136
|
-
# "profile_path"=>nil
|
137
|
-
# },
|
138
|
-
# {
|
139
|
-
# ...
|
140
|
-
# }
|
141
|
-
# ]
|
142
|
-
|
143
|
-
### Images
|
111
|
+
|
112
|
+
|
113
|
+
TMDb::Movie.crew(550, language: 'fr')
|
114
|
+
```
|
115
|
+
|
116
|
+
### Movie images
|
144
117
|
Get the images (posters and backdrops) for a specific movie id.
|
145
118
|
|
146
119
|
```ruby
|
147
120
|
TMDb::Movie.images(598)
|
148
|
-
# => {"id"=>598,
|
149
|
-
# "backdrops"=> [
|
150
|
-
# {
|
151
|
-
# "file_path"=>"/hSaH9tt67bozo9K50sbH0s4YjEc.jpg",
|
152
|
-
# "width"=>1532,
|
153
|
-
# "height"=>862,
|
154
|
-
# "iso_639_1"=>nil,
|
155
|
-
# "aspect_ratio"=>1.78,
|
156
|
-
# "vote_average"=>5.4421768707483,
|
157
|
-
# "vote_count"=>7
|
158
|
-
# },
|
159
|
-
# {
|
160
|
-
# "file_path"=>"/k4BAPrE5WkNLvpsPsiMfu8W4Zyi.jpg",
|
161
|
-
# "width"=>1920,
|
162
|
-
# "height"=>1080,
|
163
|
-
# "iso_639_1"=>nil,
|
164
|
-
# "aspect_ratio"=>1.78,
|
165
|
-
# "vote_average"=>5.399159663865546,
|
166
|
-
# "vote_count"=>5
|
167
|
-
# },
|
168
|
-
# {
|
169
|
-
# ...
|
170
|
-
# }
|
171
|
-
# ]}
|
172
121
|
|
173
122
|
TMDb::Movie.images(598, language: 'pt')
|
174
123
|
```
|
@@ -179,15 +128,6 @@ Get the plot keywords for a specific movie id.
|
|
179
128
|
|
180
129
|
```ruby
|
181
130
|
TMDb::Movie.keywords(68721)
|
182
|
-
# => [
|
183
|
-
# {"id"=>2651, "name"=>"nanotechnology"},
|
184
|
-
# {"id"=>9715, "name"=>"superhero"},
|
185
|
-
# {"id"=>180547, "name"=>"marvel cinematic universe"},
|
186
|
-
# {"id"=>156792, "name"=>"3d"},
|
187
|
-
# {"id"=>156395, "name"=>"imax"},
|
188
|
-
# {"id"=>179430, "name"=>"aftercreditsstinger"},
|
189
|
-
# {"id"=>10836, "name"=>"third part"}
|
190
|
-
# ]
|
191
131
|
```
|
192
132
|
|
193
133
|
### Movie trailers
|
@@ -196,25 +136,6 @@ Get the trailers for a specific movie id.
|
|
196
136
|
|
197
137
|
```ruby
|
198
138
|
TMDb::Movie.trailers(68721)
|
199
|
-
# => {"id"=>68721,
|
200
|
-
# "quicktime"=> [
|
201
|
-
# {
|
202
|
-
# "name"=>"Teaser"
|
203
|
-
# "sources"=> [
|
204
|
-
# {"size"=>"480p","source"=>"http://trailers.apple.com/movies/marvel/ironman3/ironman3-tlr1-m4mb0_h480p.mov"},
|
205
|
-
# {"size"=>"720p","source"=>"http://trailers.apple.com/movies/marvel/ironman3/ironman3-tlr1-m4mb0_h720p.mov"},
|
206
|
-
# {"size"=>"1080p","source"=>"http://trailers.apple.com/movies/marvel/ironman3/ironman3-tlr1-m4mb0_h1080p.mov"}
|
207
|
-
# ]
|
208
|
-
# }
|
209
|
-
# "youtube"=> [
|
210
|
-
# {
|
211
|
-
# "name"=>"Iron Man 3 Trailer 2",
|
212
|
-
# "size"=>"HD",
|
213
|
-
# "source"=>"YLorLVa95Xo",
|
214
|
-
# "type"=>"Trailer"
|
215
|
-
# }
|
216
|
-
# ]
|
217
|
-
# }
|
218
139
|
```
|
219
140
|
|
220
141
|
### Movie releases
|
@@ -223,15 +144,6 @@ Get the release date by country for a specific movie id.
|
|
223
144
|
|
224
145
|
```ruby
|
225
146
|
TMDb::Movie.releases(68721)
|
226
|
-
# => [
|
227
|
-
# {"iso_3166_1"=>"US", "certification"=>"PG-13", "release_date"=>"2013-05-03"},
|
228
|
-
# {"iso_3166_1"=>"DE", "certification"=>"12", "release_date"=>"2013-04-30"},
|
229
|
-
# {"iso_3166_1"=>"FR", "certification"=>"", "release_date"=>"2013-04-24"},
|
230
|
-
# {"iso_3166_1"=>"BG", "certification"=>"C", "release_date"=>"2013-04-26"},
|
231
|
-
# {"iso_3166_1"=>"NL", "certification"=>"", "release_date"=>"2013-04-24"},
|
232
|
-
# {"iso_3166_1"=>"NO", "certification"=>"", "release_date"=>"2013-04-26"},
|
233
|
-
# ...,
|
234
|
-
# ]
|
235
147
|
```
|
236
148
|
|
237
149
|
### Upcoming movies
|
@@ -241,45 +153,34 @@ The maximum number of items this list will include is 100.
|
|
241
153
|
|
242
154
|
```ruby
|
243
155
|
TMDb::Movie.upcoming
|
244
|
-
# => [
|
245
|
-
# #<TMDb::Movie:0x007fefa4202a10
|
246
|
-
# @adult=false,
|
247
|
-
# @backdrop_path="/rwibG3yurWQvpjut54nbeiSGhVt.jpg",
|
248
|
-
# @id=157375,
|
249
|
-
# @original_title="The Lifeguard",
|
250
|
-
# @popularity=8.708121262,
|
251
|
-
# @poster_path="/xoX6C3mLynwSNRij2tyDT5eVmoc.jpg",
|
252
|
-
# @release_date="2013-08-30",
|
253
|
-
# @title="The Lifeguard",
|
254
|
-
# @vote_average=5.5,
|
255
|
-
# @vote_count=3>
|
256
|
-
# ]
|
257
156
|
```
|
258
157
|
|
259
|
-
### Find a person by
|
158
|
+
### Find a person by id
|
260
159
|
|
261
160
|
Get the basic person information for a specific person id.
|
262
161
|
|
263
162
|
```ruby
|
264
163
|
TMDB::Person.find(138)
|
265
|
-
# => #<TMDb::Person:0x007ff02a081278 @adult=false, @id=138, @imdb_id="nm0000233", @name="Quentin Tarantino" ... >
|
266
164
|
```
|
267
165
|
|
268
|
-
Available attributes:
|
269
|
-
|
166
|
+
Available attributes: _id_, _name_, _adult_, _also_known_as_, _biography_
|
167
|
+
_birthday_, _deathday_, _homepage_, _place_of_birth_, _profile_path_,
|
168
|
+
_popularity_, _imdb_id_.
|
270
169
|
|
271
170
|
### Search people
|
272
171
|
Search for people by name.
|
273
172
|
|
274
173
|
```ruby
|
275
174
|
TMDb::Person.search('Paul')
|
276
|
-
# => [#<TMDb::Person:0x007fb572c30558 @id=8167, @name="Paul Walker", ...>,
|
277
|
-
# #<TMDb::Person:0x007fb572c302b0 @id=5129, @name="Paul Reubens", ...>, ...]
|
278
175
|
|
279
176
|
TMDb::Person.search('Paul', page: 4)
|
280
|
-
# => [#<TMDb::Person:0x007fb572d68d80 @id=455, @name="Paul Haggis", ...>, ...]
|
281
177
|
```
|
282
|
-
|
178
|
+
|
179
|
+
Optional parameters:
|
180
|
+
|
181
|
+
- `page` - Minimum 1, maximum 1000.
|
182
|
+
- `include_adult` - Toggle the inclusion of adult titles. Expected value is:
|
183
|
+
_true_ or _false_.
|
283
184
|
|
284
185
|
### Person images
|
285
186
|
|
@@ -287,51 +188,44 @@ Gets the images for a specific person id.
|
|
287
188
|
|
288
189
|
```ruby
|
289
190
|
TMDb::Person.images(138)
|
290
|
-
# => {"id" => 138,
|
291
|
-
# "profiles" => [
|
292
|
-
# {
|
293
|
-
# "file_path" => "/iws3gBdQJ6tF7x6CIpepYfUKc58.jpg",
|
294
|
-
# "width" => 1000,
|
295
|
-
# "height" => 1500,
|
296
|
-
# "iso_639_1" => nil,
|
297
|
-
# "aspect_ratio" => 0.67
|
298
|
-
# },
|
299
|
-
# {
|
300
|
-
# "file_path" => "/ubJ3VWz1Zr7dempsJGH8lgREkrS.jpg",
|
301
|
-
# "width" => 399,
|
302
|
-
# "height" => 599,
|
303
|
-
# "iso_639_1" => nil,
|
304
|
-
# "aspect_ratio" => 0.67
|
305
|
-
# }]
|
306
|
-
# }
|
307
191
|
```
|
308
192
|
|
309
193
|
### Popular people
|
310
194
|
|
311
|
-
Gets a list of popular people.
|
195
|
+
Gets a list of popular people. This list refreshes every day.
|
312
196
|
|
313
197
|
```ruby
|
314
198
|
TMDb::Person.popular
|
315
|
-
# => [
|
316
|
-
# #<TMDb::Person:0x007ff0289d1550
|
317
|
-
# @adult=false,
|
318
|
-
# @id=18918,
|
319
|
-
# @name="Dwayne Johnson",
|
320
|
-
# @popularity=27.5754694040027,
|
321
|
-
# @profile_path="/gQIWcpYo2W4MHw8UhTP2cW0jojF.jpg">,
|
322
|
-
# #<TMDb::Person:0x007ff0289d1208
|
323
|
-
# @adult=false,
|
324
|
-
# @id=12835,
|
325
|
-
# @name="Vin Diesel",
|
326
|
-
# @popularity=20.5472519159021,
|
327
|
-
# @profile_path="/qwyfzMKIhxJ7ols66FgEf7eGdcI.jpg">
|
328
|
-
# ]
|
329
199
|
```
|
330
200
|
|
201
|
+
Optional parameters:
|
202
|
+
|
203
|
+
- `page` - Minimum 1, maximum 1000.
|
204
|
+
|
205
|
+
### Changes
|
206
|
+
|
207
|
+
##### Movie changes
|
208
|
+
|
209
|
+
Get a list of movie ids that have been edited. By default we show the last 24
|
210
|
+
hours and only 100 items per page. The maximum number of days that can be
|
211
|
+
returned in a single request is 14.
|
212
|
+
|
213
|
+
```ruby
|
214
|
+
TMDb::Changes.movies
|
215
|
+
|
216
|
+
TMDb::Changes.movies(page: 1, start_date: '2013-03-22')
|
217
|
+
```
|
218
|
+
|
219
|
+
Optional parameters:
|
220
|
+
|
221
|
+
- `page` - Minimum 1, maximum 1000.
|
222
|
+
- `start_date` - YYYY-MM-DD.
|
223
|
+
- `end_date` - YYYY-MM-DD.
|
224
|
+
|
331
225
|
## Contributing
|
332
226
|
|
333
|
-
1. Fork it
|
334
|
-
2. Create your feature branch (`git checkout -b my-new-feature`)
|
335
|
-
3. Commit your changes (`git commit -am 'Add some feature'`)
|
336
|
-
4. Push to the branch (`git push origin my-new-feature`)
|
337
|
-
5. Create new Pull Request
|
227
|
+
1. Fork it.
|
228
|
+
2. Create your feature branch (`git checkout -b my-new-feature`).
|
229
|
+
3. Commit your changes (`git commit -am 'Add some feature'`).
|
230
|
+
4. Push to the branch (`git push origin my-new-feature`).
|
231
|
+
5. Create new Pull Request.
|
data/lib/tmdb-api/base.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
require 'active_support/core_ext/string'
|
2
|
-
require "pry"
|
3
2
|
|
4
3
|
module TMDb
|
5
4
|
class Base
|
@@ -26,7 +25,7 @@ module TMDb
|
|
26
25
|
#
|
27
26
|
# attributes - Attributes fetched from the API.
|
28
27
|
def initialize(attributes = {})
|
29
|
-
|
28
|
+
set_attributes(attributes)
|
30
29
|
end
|
31
30
|
|
32
31
|
private
|
@@ -37,7 +36,7 @@ module TMDb
|
|
37
36
|
# set in the object.
|
38
37
|
#
|
39
38
|
# Returns nothing
|
40
|
-
def
|
39
|
+
def set_attributes(attributes)
|
41
40
|
attributes.each do |key, value|
|
42
41
|
value = build_objects(key, value) if candidate_to_object?(value)
|
43
42
|
self.instance_variable_set("@#{key}", value)
|
data/lib/tmdb-api/changes.rb
CHANGED
@@ -1,21 +1,46 @@
|
|
1
1
|
module TMDb
|
2
2
|
class Changes < Base
|
3
|
+
ATTRIBUTES = :changes, :page, :total_pages, :total_results
|
4
|
+
|
5
|
+
attr_reader *ATTRIBUTES
|
6
|
+
|
3
7
|
# Public: Get a list of movie ids that have been edited. By default we
|
4
8
|
# show the last 24 hours and only 100 items per page. The maximum number
|
5
9
|
# of days that can be returned in a single request is 14.
|
6
10
|
#
|
7
11
|
# options - The hash options used to filter the search (default: {}).
|
8
|
-
# :page - Page.
|
12
|
+
# :page - Page. Minimum 1, maximum 1000.
|
9
13
|
# :start_date - Start date (YYYY-MM-DD).
|
10
14
|
# :end_date - End date (YYYY-MM-DD).
|
11
15
|
#
|
12
16
|
# Examples
|
13
17
|
#
|
14
|
-
#
|
15
|
-
#
|
18
|
+
# TMDb::Changes.movies
|
19
|
+
# TMDb::Changes.movies(page: 1, start_date: '2013-03-22')
|
16
20
|
def self.movies(options = {})
|
17
21
|
res = get('/movie/changes', query: options)
|
18
|
-
res.success? ? res : bad_response(res)
|
22
|
+
res.success? ? Changes.new(res) : bad_response(res)
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
# Internal: sets the fetched result to the instance variables.
|
28
|
+
#
|
29
|
+
# attributes - Returned attributes from the API.
|
30
|
+
def set_attributes(attributes)
|
31
|
+
@changes = results_ids(attributes['results'])
|
32
|
+
@page = attributes['page']
|
33
|
+
@total_pages = attributes['total_pages']
|
34
|
+
@total_results = attributes['total_results']
|
35
|
+
end
|
36
|
+
|
37
|
+
# Internal: Extract only the IDs from the result.
|
38
|
+
#
|
39
|
+
# changes - The `results` key returned from the API.
|
40
|
+
def results_ids(changes)
|
41
|
+
changes.map do |item|
|
42
|
+
item['id']
|
43
|
+
end
|
19
44
|
end
|
20
45
|
end
|
21
46
|
end
|