themoviedb 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 +5 -5
- data/README.md +10 -5
- data/lib/themoviedb/api.rb +5 -5
- data/lib/themoviedb/collection.rb +1 -1
- data/lib/themoviedb/company.rb +1 -1
- data/lib/themoviedb/configuration.rb +8 -8
- data/lib/themoviedb/episode.rb +3 -3
- data/lib/themoviedb/find.rb +6 -6
- data/lib/themoviedb/genre.rb +5 -5
- data/lib/themoviedb/job.rb +1 -1
- data/lib/themoviedb/keyword.rb +20 -0
- data/lib/themoviedb/movie.rb +15 -9
- data/lib/themoviedb/person.rb +3 -3
- data/lib/themoviedb/resource.rb +1 -1
- data/lib/themoviedb/search.rb +22 -20
- data/lib/themoviedb/season.rb +3 -3
- data/lib/themoviedb/tv.rb +6 -6
- data/lib/themoviedb/version.rb +2 -1
- data/lib/themoviedb.rb +6 -6
- data/spec/company_spec.rb +30 -32
- data/spec/find_spec.rb +14 -16
- data/spec/invalid_api_key_spec.rb +13 -14
- data/spec/keyword_spec.rb +66 -0
- data/spec/movie_spec.rb +134 -133
- data/spec/person_spec.rb +60 -63
- data/spec/spec_helper.rb +13 -17
- data/spec/tv_spec.rb +175 -177
- data/spec/vcr/keyword/detail.yml +56 -0
- data/spec/vcr/keyword/movies_for_id.yml +334 -0
- data/spec/vcr/movie/detail.yml +22 -56
- data/themoviedb.gemspec +1 -7
- metadata +50 -100
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: dfa53da968e8f3a8677c560d6fa37b61c49ac98fa255d199cd5eb5447cb78dfc
|
4
|
+
data.tar.gz: bc66fd583f7bfa9ef7c6f22cd89a1a8eb3ba98f7c570ed97bcf17c3423559004
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e74d886d5af9bb982d5451c3328d8fe939547eef1f9a8e479941604c44aa4907ea4f304571c24a679f5edb8a8f7356cb1e7c5a1fd9df2b3c0d11217fa2e00304
|
7
|
+
data.tar.gz: 9e17d6f2d762b4f9ecddce6668dceecb755770f4b3a4b1dc901fa15468c9e897ff12599d4a66de90ef5a5eebed34b241aa861ee116f662d1d7b17f2f50f370c8
|
data/README.md
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
-
|
1
|
+
# themoviedb
|
2
2
|
|
3
|
-
|
3
|
+
[![Code Climate](https://codeclimate.com/github/ahmetabdi/themoviedb/badges/gpa.svg)](https://codeclimate.com/github/ahmetabdi/themoviedb) [![Gem Version](https://badge.fury.io/rb/themoviedb.png)](http://badge.fury.io/rb/themoviedb)
|
4
4
|
|
5
5
|
A Ruby wrapper for the [The Movie Database API](http://docs.themoviedb.apiary.io/).
|
6
6
|
|
7
|
-
Ruby >= 1
|
7
|
+
`Ruby >= 3.1`
|
8
8
|
|
9
9
|
Provides a simple, easy to use interface for the Movie Database API.
|
10
10
|
|
@@ -78,7 +78,7 @@ Tmdb::Genre.find("drama")
|
|
78
78
|
|
79
79
|
### Usage
|
80
80
|
|
81
|
-
resources => person, movie, tv, collection, company
|
81
|
+
resources => person, movie, tv, collection, company, multi
|
82
82
|
|
83
83
|
```ruby
|
84
84
|
@search = Tmdb::Search.new
|
@@ -198,6 +198,11 @@ Get the cast information for a specific movie id.
|
|
198
198
|
```ruby
|
199
199
|
Tmdb::Movie.casts(22855)
|
200
200
|
```
|
201
|
+
#### Movie - Crew
|
202
|
+
Get the crew information for a specific movie id.
|
203
|
+
```ruby
|
204
|
+
Tmdb::Movie.crew(22855)
|
205
|
+
```
|
201
206
|
#### Movie - Keywords
|
202
207
|
Get the plot keywords for a specific movie id.
|
203
208
|
```ruby
|
@@ -442,7 +447,7 @@ Tmdb::Job.list
|
|
442
447
|
|
443
448
|
themoviedb - A ruby wrapper for the movie database API
|
444
449
|
|
445
|
-
Copyright (C)
|
450
|
+
Copyright (C) 2024 Ahmet Abdi
|
446
451
|
|
447
452
|
This program is free software; you can redistribute it and/or
|
448
453
|
modify it under the terms of the GNU General Public License
|
data/lib/themoviedb/api.rb
CHANGED
@@ -2,10 +2,10 @@ module Tmdb
|
|
2
2
|
class InvalidApiKeyError < StandardError ; end
|
3
3
|
class Api
|
4
4
|
include HTTParty
|
5
|
-
base_uri
|
5
|
+
base_uri "api.themoviedb.org/3/"
|
6
6
|
format :json
|
7
|
-
headers
|
8
|
-
headers
|
7
|
+
headers "Accept" => "application/json"
|
8
|
+
headers "Content-Type" => "application/json"
|
9
9
|
|
10
10
|
def self.config
|
11
11
|
@@config ||= {}
|
@@ -24,7 +24,7 @@ module Tmdb
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def self.etag(etag)
|
27
|
-
headers
|
27
|
+
headers "If-None-Match" => '"' + etag + '"'
|
28
28
|
end
|
29
29
|
|
30
30
|
def self.response
|
@@ -34,7 +34,7 @@ module Tmdb
|
|
34
34
|
def self.set_response(hash)
|
35
35
|
@@response = hash
|
36
36
|
# Detect 401 Unauthorized error, which indicates invalid API key
|
37
|
-
raise Tmdb::InvalidApiKeyError if hash[
|
37
|
+
raise Tmdb::InvalidApiKeyError if hash["code"].to_i == 401
|
38
38
|
end
|
39
39
|
end
|
40
40
|
end
|
data/lib/themoviedb/company.rb
CHANGED
@@ -2,7 +2,7 @@ module Tmdb
|
|
2
2
|
class Configuration
|
3
3
|
def initialize
|
4
4
|
@params = {}
|
5
|
-
@resource =
|
5
|
+
@resource = "/configuration"
|
6
6
|
self
|
7
7
|
end
|
8
8
|
|
@@ -11,28 +11,28 @@ module Tmdb
|
|
11
11
|
# Simply combine them all and you will have a fully qualified URL. Here’s an example URL:
|
12
12
|
# http://cf2.imgobject.com/t/p/w500/8uO0gUM8aNqYLs1OsTBQiXu0fEv.jpg
|
13
13
|
def base_url
|
14
|
-
images_config[
|
14
|
+
images_config["base_url"]
|
15
15
|
end
|
16
16
|
|
17
17
|
# HTTPS
|
18
18
|
def secure_base_url
|
19
|
-
images_config[
|
19
|
+
images_config["secure_base_url"]
|
20
20
|
end
|
21
21
|
|
22
22
|
def poster_sizes
|
23
|
-
images_config[
|
23
|
+
images_config["poster_sizes"]
|
24
24
|
end
|
25
25
|
|
26
26
|
def backdrop_sizes
|
27
|
-
images_config[
|
27
|
+
images_config["backdrop_sizes"]
|
28
28
|
end
|
29
29
|
|
30
30
|
def profile_sizes
|
31
|
-
images_config[
|
31
|
+
images_config["profile_sizes"]
|
32
32
|
end
|
33
33
|
|
34
34
|
def logo_sizes
|
35
|
-
images_config[
|
35
|
+
images_config["logo_sizes"]
|
36
36
|
end
|
37
37
|
|
38
38
|
def fetch_response
|
@@ -44,7 +44,7 @@ module Tmdb
|
|
44
44
|
private
|
45
45
|
|
46
46
|
def images_config
|
47
|
-
@images_config ||= fetch_response[
|
47
|
+
@images_config ||= fetch_response["images"] || {}
|
48
48
|
end
|
49
49
|
end
|
50
50
|
end
|
data/lib/themoviedb/episode.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
module Tmdb
|
2
2
|
class Episode < Resource
|
3
|
-
has_resource
|
3
|
+
has_resource "episode", plural: "episodes"
|
4
4
|
|
5
5
|
# Get the primary information about a TV episode by combination of a season and episode number.
|
6
6
|
def self.detail(id, season, episode, conditions = {})
|
@@ -12,13 +12,13 @@ module Tmdb
|
|
12
12
|
# Get the TV episode cast credits by combination of season and episode number.
|
13
13
|
def self.cast(id, season, episode, _conditions = {})
|
14
14
|
search = Tmdb::Search.new("/tv/#{endpoint_id + id.to_s}/season/#{endpoint_id + season.to_s}/#{endpoints[:singular]}/#{endpoint_id + episode.to_s}/credits")
|
15
|
-
search.fetch_response[
|
15
|
+
search.fetch_response["cast"]
|
16
16
|
end
|
17
17
|
|
18
18
|
# Get the TV episode crew credits by combination of season and episode number.
|
19
19
|
def self.crew(id, season, episode, _conditions = {})
|
20
20
|
search = Tmdb::Search.new("/tv/#{endpoint_id + id.to_s}/season/#{endpoint_id + season.to_s}/#{endpoints[:singular]}/#{endpoint_id + episode.to_s}/credits")
|
21
|
-
search.fetch_response[
|
21
|
+
search.fetch_response["crew"]
|
22
22
|
end
|
23
23
|
|
24
24
|
# Get the external ids for a TV episode by comabination of a season and episode number.
|
data/lib/themoviedb/find.rb
CHANGED
@@ -1,30 +1,30 @@
|
|
1
1
|
module Tmdb
|
2
2
|
class Find < Resource
|
3
|
-
has_resource
|
3
|
+
has_resource "find"
|
4
4
|
|
5
5
|
def self.imdb_id(id, _conditions = {})
|
6
6
|
search = Tmdb::Search.new("/#{endpoints[:singular]}/#{endpoint_id + id.to_s}")
|
7
|
-
search.fetch_response(external_source:
|
7
|
+
search.fetch_response(external_source: "imdb_id")
|
8
8
|
end
|
9
9
|
|
10
10
|
def self.freebase_mid(id, _conditions = {})
|
11
11
|
search = Tmdb::Search.new("/#{endpoints[:singular]}/#{endpoint_id + id.to_s}")
|
12
|
-
search.fetch_response(external_source:
|
12
|
+
search.fetch_response(external_source: "freebase_mid")
|
13
13
|
end
|
14
14
|
|
15
15
|
def self.freebase_id(id, _conditions = {})
|
16
16
|
search = Tmdb::Search.new("/#{endpoints[:singular]}/#{endpoint_id + id.to_s}")
|
17
|
-
search.fetch_response(external_source:
|
17
|
+
search.fetch_response(external_source: "freebase_id")
|
18
18
|
end
|
19
19
|
|
20
20
|
def self.tvrage_id(id, _conditions = {})
|
21
21
|
search = Tmdb::Search.new("/#{endpoints[:singular]}/#{endpoint_id + id.to_s}")
|
22
|
-
search.fetch_response(external_source:
|
22
|
+
search.fetch_response(external_source: "tvrage_id")
|
23
23
|
end
|
24
24
|
|
25
25
|
def self.tvdb_id(id, _conditions = {})
|
26
26
|
search = Tmdb::Search.new("/#{endpoints[:singular]}/#{endpoint_id + id.to_s}")
|
27
|
-
search.fetch_response(external_source:
|
27
|
+
search.fetch_response(external_source: "tvdb_id")
|
28
28
|
end
|
29
29
|
end
|
30
30
|
end
|
data/lib/themoviedb/genre.rb
CHANGED
@@ -20,7 +20,7 @@ module Tmdb
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def self.search(query)
|
23
|
-
detail(list[
|
23
|
+
detail(list["genres"].detect { |g| g["name"] == query }["id"])
|
24
24
|
end
|
25
25
|
|
26
26
|
class << self
|
@@ -28,17 +28,17 @@ module Tmdb
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def self.list
|
31
|
-
search = Tmdb::Search.new(
|
31
|
+
search = Tmdb::Search.new("/genre/list")
|
32
32
|
search.fetch_response
|
33
33
|
end
|
34
34
|
|
35
35
|
def self.detail(id, conditions = {})
|
36
36
|
url = "/genre/#{id}/movies"
|
37
37
|
unless conditions.empty?
|
38
|
-
url <<
|
38
|
+
url << "?"
|
39
39
|
conditions.each_with_index do |(key, value), index|
|
40
40
|
url << "#{key}=#{value}"
|
41
|
-
url <<
|
41
|
+
url << "&" if index != conditions.length - 1
|
42
42
|
end
|
43
43
|
end
|
44
44
|
search = Tmdb::Search.new(url)
|
@@ -46,7 +46,7 @@ module Tmdb
|
|
46
46
|
end
|
47
47
|
|
48
48
|
def name
|
49
|
-
@name ||= self.class.list[
|
49
|
+
@name ||= self.class.list["genres"].detect { |g| g["id"] == @id }["name"]
|
50
50
|
end
|
51
51
|
|
52
52
|
def get_page(page_number, conditions = {})
|
data/lib/themoviedb/job.rb
CHANGED
@@ -0,0 +1,20 @@
|
|
1
|
+
module Tmdb
|
2
|
+
class Keyword < Resource
|
3
|
+
has_resource "keyword", plural: "keywords"
|
4
|
+
|
5
|
+
# http://docs.themoviedb.apiary.io/#keywords
|
6
|
+
@@fields = [
|
7
|
+
:id,
|
8
|
+
:name
|
9
|
+
]
|
10
|
+
|
11
|
+
@@fields.each do |field|
|
12
|
+
attr_accessor field
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.movies(id, _conditions = {})
|
16
|
+
search = Tmdb::Search.new("/#{endpoints[:singular]}/#{endpoint_id + id.to_s}/movies")
|
17
|
+
search.fetch.collect { |result| Tmdb::Movie.new(result) }
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
data/lib/themoviedb/movie.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
module Tmdb
|
2
2
|
class Movie < Resource
|
3
|
-
has_resource
|
3
|
+
has_resource "movie", plural: "movies"
|
4
4
|
|
5
5
|
# http://docs.themoviedb.apiary.io/#movies
|
6
6
|
@@fields = [
|
@@ -12,6 +12,7 @@ module Tmdb
|
|
12
12
|
:homepage,
|
13
13
|
:id,
|
14
14
|
:imdb_id,
|
15
|
+
:original_language,
|
15
16
|
:original_title,
|
16
17
|
:overview,
|
17
18
|
:popularity,
|
@@ -45,37 +46,37 @@ module Tmdb
|
|
45
46
|
|
46
47
|
# Get the latest movie id. singular
|
47
48
|
def self.latest
|
48
|
-
search = Tmdb::Search.new(
|
49
|
+
search = Tmdb::Search.new("/movie/latest")
|
49
50
|
new(search.fetch_response)
|
50
51
|
end
|
51
52
|
|
52
53
|
# Get the list of upcoming movies. This list refreshes every day. The maximum number of items this list will include is 100.
|
53
54
|
def self.upcoming
|
54
|
-
search = Tmdb::Search.new(
|
55
|
+
search = Tmdb::Search.new("/movie/upcoming")
|
55
56
|
search.fetch.collect { |result| new(result) }
|
56
57
|
end
|
57
58
|
|
58
59
|
# Get the list of movies playing in theatres. This list refreshes every day. The maximum number of items this list will include is 100.
|
59
60
|
def self.now_playing
|
60
|
-
search = Tmdb::Search.new(
|
61
|
+
search = Tmdb::Search.new("/movie/now_playing")
|
61
62
|
search.fetch.collect { |result| new(result) }
|
62
63
|
end
|
63
64
|
|
64
65
|
# Get the list of popular movies on The Movie Database. This list refreshes every day.
|
65
66
|
def self.popular
|
66
|
-
search = Tmdb::Search.new(
|
67
|
+
search = Tmdb::Search.new("/movie/popular")
|
67
68
|
search.fetch.collect { |result| new(result) }
|
68
69
|
end
|
69
70
|
|
70
71
|
# Get the list of top rated movies. By default, this list will only include movies that have 10 or more votes. This list refreshes every day.
|
71
72
|
def self.top_rated
|
72
|
-
search = Tmdb::Search.new(
|
73
|
+
search = Tmdb::Search.new("/movie/top_rated")
|
73
74
|
search.fetch.collect { |result| new(result) }
|
74
75
|
end
|
75
76
|
|
76
77
|
# Discover movies by different types of data like average rating, number of votes, genres and certifications.
|
77
78
|
def self.discover(conditions = {})
|
78
|
-
search = Tmdb::Search.new(
|
79
|
+
search = Tmdb::Search.new("/discover/movie")
|
79
80
|
search.filter(conditions)
|
80
81
|
search.fetch.collect { |result| new(result) }
|
81
82
|
end
|
@@ -89,13 +90,13 @@ module Tmdb
|
|
89
90
|
# Get the cast information for a specific movie id.
|
90
91
|
def self.casts(id, _conditions = {})
|
91
92
|
search = Tmdb::Search.new("/#{endpoints[:singular]}/#{endpoint_id + id.to_s}/casts")
|
92
|
-
search.fetch_response[
|
93
|
+
search.fetch_response["cast"]
|
93
94
|
end
|
94
95
|
|
95
96
|
# Get the cast information for a specific movie id.
|
96
97
|
def self.crew(id, _conditions = {})
|
97
98
|
search = Tmdb::Search.new("/#{endpoints[:singular]}/#{endpoint_id + id.to_s}/casts")
|
98
|
-
search.fetch_response[
|
99
|
+
search.fetch_response["crew"]
|
99
100
|
end
|
100
101
|
|
101
102
|
# Get the images (posters and backdrops) for a specific movie id.
|
@@ -156,5 +157,10 @@ module Tmdb
|
|
156
157
|
search = Tmdb::Search.new("/#{endpoints[:singular]}/#{endpoint_id + id.to_s}/credits")
|
157
158
|
search.fetch_response
|
158
159
|
end
|
160
|
+
|
161
|
+
def self.videos(id, _conditions = {})
|
162
|
+
search = Tmdb::Search.new("/#{endpoints[:singular]}/#{endpoint_id + id.to_s}/videos")
|
163
|
+
search.fetch_response
|
164
|
+
end
|
159
165
|
end
|
160
166
|
end
|
data/lib/themoviedb/person.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
module Tmdb
|
2
2
|
class Person < Resource
|
3
|
-
has_resource
|
3
|
+
has_resource "person", plural: "people"
|
4
4
|
|
5
5
|
# http://docs.themoviedb.apiary.io/#people
|
6
6
|
@@fields = [
|
@@ -30,8 +30,8 @@ module Tmdb
|
|
30
30
|
def self.popular
|
31
31
|
search = Tmdb::Search.new("/#{endpoints[:singular]}/popular")
|
32
32
|
search.fetch.collect do |result|
|
33
|
-
next unless result[
|
34
|
-
result[
|
33
|
+
next unless result["known_for"]
|
34
|
+
result["known_for"] = result["known_for"].collect { |movie| Tmdb::Movie.new(movie) }
|
35
35
|
new(result)
|
36
36
|
end
|
37
37
|
end
|
data/lib/themoviedb/resource.rb
CHANGED
@@ -8,7 +8,7 @@ module Tmdb
|
|
8
8
|
singular: singular.nil? ? name.downcase.to_s : singular,
|
9
9
|
plural: opts[:plural].nil? ? "#{name.downcase}s" : opts[:plural]
|
10
10
|
}
|
11
|
-
@@endpoint_id[name.downcase] = opts[:id].nil? ?
|
11
|
+
@@endpoint_id[name.downcase] = opts[:id].nil? ? "" : "#{opts[:id]}-"
|
12
12
|
end
|
13
13
|
|
14
14
|
def self.endpoints
|
data/lib/themoviedb/search.rb
CHANGED
@@ -2,7 +2,7 @@ module Tmdb
|
|
2
2
|
class Search
|
3
3
|
def initialize(resource = nil)
|
4
4
|
@params = {}
|
5
|
-
@resource = resource.nil? ?
|
5
|
+
@resource = resource.nil? ? "/search/movie" : resource
|
6
6
|
self
|
7
7
|
end
|
8
8
|
|
@@ -23,22 +23,24 @@ module Tmdb
|
|
23
23
|
|
24
24
|
def resource(resource)
|
25
25
|
@resource = case resource
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
26
|
+
when "movie"
|
27
|
+
"/search/movie"
|
28
|
+
when "collection"
|
29
|
+
"/search/collection"
|
30
|
+
when "tv"
|
31
|
+
"/search/tv"
|
32
|
+
when "person"
|
33
|
+
"/search/person"
|
34
|
+
when "list"
|
35
|
+
"/search/list"
|
36
|
+
when "company"
|
37
|
+
"/search/company"
|
38
|
+
when "keyword"
|
39
|
+
"/search/keyword"
|
40
|
+
when "multi"
|
41
|
+
"/search/multi"
|
42
|
+
when "find"
|
43
|
+
"/find"
|
42
44
|
end
|
43
45
|
self
|
44
46
|
end
|
@@ -57,7 +59,7 @@ module Tmdb
|
|
57
59
|
|
58
60
|
# Sends back main data
|
59
61
|
def fetch
|
60
|
-
fetch_response[
|
62
|
+
fetch_response["results"]
|
61
63
|
end
|
62
64
|
|
63
65
|
# Send back whole response
|
@@ -69,10 +71,10 @@ module Tmdb
|
|
69
71
|
end
|
70
72
|
response = Api.get(@resource, query: options)
|
71
73
|
|
72
|
-
original_etag = response.headers.fetch(
|
74
|
+
original_etag = response.headers.fetch("etag", "")
|
73
75
|
etag = original_etag.delete('"')
|
74
76
|
|
75
|
-
Api.set_response(
|
77
|
+
Api.set_response("code" => response.code, "etag" => etag)
|
76
78
|
response.to_hash
|
77
79
|
end
|
78
80
|
end
|
data/lib/themoviedb/season.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
module Tmdb
|
2
2
|
class Season < Resource
|
3
|
-
has_resource
|
3
|
+
has_resource "season", plural: "seasons"
|
4
4
|
|
5
5
|
# Get the primary information about a TV season by its season number.
|
6
6
|
def self.detail(id, season, conditions = {})
|
@@ -12,13 +12,13 @@ module Tmdb
|
|
12
12
|
# Get the cast credits for a TV season by season number.
|
13
13
|
def self.cast(id, season, _conditions = {})
|
14
14
|
search = Tmdb::Search.new("/tv/#{endpoint_id + id.to_s}/#{endpoints[:singular]}/#{endpoint_id + season.to_s}/credits")
|
15
|
-
search.fetch_response[
|
15
|
+
search.fetch_response["cast"]
|
16
16
|
end
|
17
17
|
|
18
18
|
# Get the crew credits for a TV season by season number.
|
19
19
|
def self.crew(id, season, _conditions = {})
|
20
20
|
search = Tmdb::Search.new("/tv/#{endpoint_id + id.to_s}/#{endpoints[:singular]}/#{endpoint_id + season.to_s}/credits")
|
21
|
-
search.fetch_response[
|
21
|
+
search.fetch_response["crew"]
|
22
22
|
end
|
23
23
|
|
24
24
|
# Get the external ids that we have stored for a TV season by season number.
|
data/lib/themoviedb/tv.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
module Tmdb
|
2
2
|
class TV < Resource
|
3
|
-
has_resource
|
3
|
+
has_resource "tv", plural: "tv"
|
4
4
|
|
5
5
|
# http://docs.themoviedb.apiary.io/#tv
|
6
6
|
@@fields = [
|
@@ -37,19 +37,19 @@ module Tmdb
|
|
37
37
|
|
38
38
|
# Get the list of popular TV shows. This list refreshes every day.
|
39
39
|
def self.popular
|
40
|
-
search = Tmdb::Search.new(
|
40
|
+
search = Tmdb::Search.new("/tv/popular")
|
41
41
|
search.fetch.collect { |result| new(result) }
|
42
42
|
end
|
43
43
|
|
44
44
|
# Get the list of top rated TV shows. By default, this list will only include TV shows that have 2 or more votes. This list refreshes every day.
|
45
45
|
def self.top_rated
|
46
|
-
search = Tmdb::Search.new(
|
46
|
+
search = Tmdb::Search.new("/tv/top_rated")
|
47
47
|
search.fetch.collect { |result| new(result) }
|
48
48
|
end
|
49
49
|
|
50
50
|
# Discover TV shows by different types of data like average rating, number of votes, genres, the network they aired on and air dates
|
51
51
|
def self.discover(conditions = {})
|
52
|
-
search = Tmdb::Search.new(
|
52
|
+
search = Tmdb::Search.new("/discover/tv")
|
53
53
|
search.filter(conditions)
|
54
54
|
search.fetch.collect { |result| new(result) }
|
55
55
|
end
|
@@ -57,13 +57,13 @@ module Tmdb
|
|
57
57
|
# Get the cast information about a TV series.
|
58
58
|
def self.cast(id, _conditions = {})
|
59
59
|
search = Tmdb::Search.new("/#{endpoints[:singular]}/#{endpoint_id + id.to_s}/credits")
|
60
|
-
search.fetch_response[
|
60
|
+
search.fetch_response["cast"]
|
61
61
|
end
|
62
62
|
|
63
63
|
# Get the crew information about a TV series.
|
64
64
|
def self.crew(id, _conditions = {})
|
65
65
|
search = Tmdb::Search.new("/#{endpoints[:singular]}/#{endpoint_id + id.to_s}/credits")
|
66
|
-
search.fetch_response[
|
66
|
+
search.fetch_response["crew"]
|
67
67
|
end
|
68
68
|
|
69
69
|
# Get the external ids that we have stored for a TV series.
|
data/lib/themoviedb/version.rb
CHANGED
data/lib/themoviedb.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "rubygems"
|
2
|
+
require "httparty"
|
3
3
|
|
4
|
-
%w
|
5
|
-
require File.join(File.dirname(__FILE__),
|
4
|
+
%w[api search resource configuration].each do |inc|
|
5
|
+
require File.join(File.dirname(__FILE__), "themoviedb", inc)
|
6
6
|
end
|
7
7
|
|
8
|
-
%w
|
9
|
-
require File.join(File.dirname(__FILE__),
|
8
|
+
%w[movie tv season episode collection person company genre find job keyword].each do |inc|
|
9
|
+
require File.join(File.dirname(__FILE__), "themoviedb", inc)
|
10
10
|
end
|