Class: TMDBParty::Base
- Inherits:
-
Object
- Object
- TMDBParty::Base
- Includes:
- HTTParty, HTTParty::Icebox
- Defined in:
- lib/tmdb_party.rb
Instance Method Summary collapse
-
#browse(params = {}, lang = @default_lang) ⇒ Object
Read more about the parameters that can be passed to this method here: api.themoviedb.org/2.1/methods/Movie.browse.
- #get_file_info(file, lang = @default_lang) ⇒ Object
- #get_genres(lang = @default_lang) ⇒ Object
- #get_info(id, lang = @default_lang) ⇒ Object
- #get_person(id, lang = @default_lang) ⇒ Object
- #imdb_lookup(imdb_id, lang = @default_lang) ⇒ Object
-
#initialize(key, lang = 'en') ⇒ Base
constructor
A new instance of Base.
- #search(query, lang = @default_lang) ⇒ Object
- #search_person(query, lang = @default_lang) ⇒ Object
Methods included from HTTParty::Icebox
Constructor Details
#initialize(key, lang = 'en') ⇒ Base
Returns a new instance of Base.
16 17 18 19 |
# File 'lib/tmdb_party.rb', line 16 def initialize(key, lang = 'en') @api_key = key @default_lang = lang end |
Instance Method Details
#browse(params = {}, lang = @default_lang) ⇒ Object
Read more about the parameters that can be passed to this method here: api.themoviedb.org/2.1/methods/Movie.browse
29 30 31 32 33 |
# File 'lib/tmdb_party.rb', line 29 def browse(params = {}, lang = @default_lang) data = self.class.get(method_url('Movie.browse', lang), :query => {:order => "asc", :order_by => "title"}.merge(params)) result_or_empty_array(data, Movie) end |
#get_file_info(file, lang = @default_lang) ⇒ Object
55 56 57 58 59 60 61 |
# File 'lib/tmdb_party.rb', line 55 def get_file_info(file, lang=@default_lang) hash = TMDBParty::MovieHasher.compute_hash(file) bytesize = file.size data = self.class.get(method_url('Media.getInfo', lang, hash, bytesize)) result_or_empty_array(data, Movie) end |
#get_genres(lang = @default_lang) ⇒ Object
68 69 70 71 |
# File 'lib/tmdb_party.rb', line 68 def get_genres(lang = @default_lang) data = self.class.get(method_url('Genres.getList', lang)).parsed_response data[1..-1].collect { |genre| Genre.new(genre) } # Skips the first, see spec/fixtures/genres_results.json end |
#get_info(id, lang = @default_lang) ⇒ Object
50 51 52 53 |
# File 'lib/tmdb_party.rb', line 50 def get_info(id, lang = @default_lang) data = self.class.get(method_url('Movie.getInfo', lang, id)).parsed_response Movie.new(data.first, self) end |
#get_person(id, lang = @default_lang) ⇒ Object
63 64 65 66 |
# File 'lib/tmdb_party.rb', line 63 def get_person(id, lang = @default_lang) data = self.class.get(method_url('Person.getInfo', lang, id)).parsed_response Person.new(data.first, self) end |
#imdb_lookup(imdb_id, lang = @default_lang) ⇒ Object
41 42 43 44 45 46 47 48 |
# File 'lib/tmdb_party.rb', line 41 def imdb_lookup(imdb_id, lang = @default_lang) data = self.class.get(method_url('Movie.imdbLookup', lang, imdb_id)).parsed_response if data.class != Array || data.first == "Nothing found." nil else Movie.new(data.first, self) end end |
#search(query, lang = @default_lang) ⇒ Object
21 22 23 24 25 |
# File 'lib/tmdb_party.rb', line 21 def search(query, lang = @default_lang) data = self.class.get(method_url('Movie.search', lang, query)) result_or_empty_array(data, Movie) end |
#search_person(query, lang = @default_lang) ⇒ Object
35 36 37 38 39 |
# File 'lib/tmdb_party.rb', line 35 def search_person(query, lang = @default_lang) data = self.class.get(method_url('Person.search', lang, query)) result_or_empty_array(data, Person) end |