Giter Club home page Giter Club logo

themoviedb's Introduction

Information

themoviedb Code Climate Gem Version

A Ruby wrapper for the The Movie Database API.

Ruby >= 1.9.3

Provides a simple, easy to use interface for the Movie Database API.

Get your API key here.

Getting started

$ gem install themoviedb

Example usage of the 'themovedb' gem

http://themoviedb.herokuapp.com/

https://github.com/ahmetabdi/themoviedb-example

Configuration

Tmdb::Api.key("KEY_HERE")

You can change the language for the returned data with this:

Tmdb::Api.language("de")

The default language is english. The API supports translations just be aware that it does not fall back to English in the event that a field hasn't been translated.

Resources

Current available resources:

Missing resources:

  • Account
  • Authentication
  • Changes
  • Collections
  • Credits
  • Discover
  • Keywords
  • Lists
  • Networks
  • Reviews

Example

Tmdb::Movie.find("batman")
Tmdb::TV.find("fringe")
Tmdb::Collection.find("spiderman")
Tmdb::Person.find("samuel jackson")
Tmdb::Company.find("lucas")
Tmdb::Genre.find("drama")

Search

Usage

resources => person, movie, tv, collection, company, multi

@search = Tmdb::Search.new
@search.resource('person') # determines type of resource
@search.query('samuel jackson') # the query to search against
@search.fetch # makes request

Find

The supported external sources for each object are as follows: Movies: imdb_id People: imdb_id, freebase_mid, freebase_id, tvrage_id TV Series: imdb_id, freebase_mid, freebase_id, tvdb_id, tvrage_id

Tmdb::Find.imdb_id('id')
Tmdb::Find.freebase_mid('id')
Tmdb::Find.freebase_id('id')
Tmdb::Find.tvrage_id('id')
Tmdb::Find.tvdb_id('id')

The responses are in the hash with movie_results, person_results and tv_results

Configuration

Get the system wide configuration information. Some elements of the API require some knowledge of this configuration data. The purpose of this is to try and keep the actual API responses as light as possible. This method currently holds the data relevant to building image URLs as well as the change key map. To build an image URL, you will need 3 pieces of data. The base_url, size and file_path. Simply combine them all and you will have a fully qualified URL. Here’s an example URL: http://cf2.imgobject.com/t/p/w500/8uO0gUM8aNqYLs1OsTBQiXu0fEv.jpg

configuration = Tmdb::Configuration.new
configuration.base_url
configuration.secure_base_url
configuration.poster_sizes
configuration.backdrop_sizes
configuration.profile_sizes
configuration.logo_sizes

Detail

Every example documented below uses the movie Fight Club (id 550), the TV show Breaking Bad (id 1396), and every person uses Brad Pitt (id 287). These are only used as examples to show what a real world request looks like.

Movie

movie = Tmdb::Movie.detail(550)
movie.adult => false
movie.backdrop_path => "/8uO0gUM8aNqYLs1OsTBQiXu0fEv.jpg"
movie.belongs_to_collection => nil
movie.budget => 63000000
movie.genres => [{"id"=>28, "name"=>"Action"}, {"id"=>18, "name"=>"Drama"}, {"id"=>53, "name"=>"Thriller"}]
movie.homepage => ""
movie.id => 550
movie.imdb_id => "tt0137523"
movie.original_title => "Fight Club"
movie.overview => "A ticking-time-bomb insomniac and a slippery soap salesman channel primal male aggression into a shocking new form of therapy. Their concept catches on, with underground \"fight clubs\" forming in every town, until an eccentric gets in the way and ignites an out-of-control spiral toward oblivion."
movie.popularity => 7.4
movie.poster_path => "/2lECpi35Hnbpa4y46JX0aY3AWTy.jpg"
movie.production_companies => [{"name"=>"20th Century Fox", "id"=>25}, {"name"=>"Fox 2000 Pictures", "id"=> 711}, {"name"=>"Regency Enterprises", "id"=>508}]
movie.production_countries => [{"iso_3166_1"=>"DE", "name"=>"Germany"}, {"iso_3166_1"=>"US", "name"=>"United States of America"}]
movie.release_date => "1999-10-14"
movie.revenue => 100853753
movie.runtime => 139
movie.spoken_languages => [{"iso_639_1"=>"en", "name"=>"English"}]
movie.status => "Released"
movie.tagline => "How much can you know about yourself if you've never been in a fight?"
movie.title => "Fight Club"
movie.vote_average => 8.8
movie.vote_count => 234

Get the latest movie id.

Tmdb::Movie.latest

Get the list of upcoming movies. This list refreshes every day. The maximum number of items this list will include is 100.

Tmdb::Movie.upcoming

Get the list of movies playing in theatres. This list refreshes every day. The maximum number of items this list will include is 100.

Tmdb::Movie.now_playing

Get the list of popular movies on The Movie Database. This list refreshes every day.

Tmdb::Movie.popular

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.

Tmdb::Movie.top_rated

Movie - Alternative Titles

Get the alternative titles for a specific movie id.

Tmdb::Movie.alternative_titles(22855)

Movie - Images

Get the images (posters and backdrops) for a specific movie id.

@movie = Tmdb::Movie.images(22855)

Grab Backdrops

@movie['backdrops']

Grab Posters

@movie['posters']

Movie - Casts

Get the cast information for a specific movie id.

Tmdb::Movie.casts(22855)

Movie - Crew

Get the crew information for a specific movie id.

Tmdb::Movie.crew(22855)

Movie - Keywords

Get the plot keywords for a specific movie id.

Tmdb::Movie.keywords(22855)

Movie - Releases

Get the release date by country for a specific movie id.

Tmdb::Movie.releases(22855)

Movie - Trailers

Get the trailers for a specific movie id.

Tmdb::Movie.trailers(22855)

Movie - Translations

Get the translations for a specific movie id.

Tmdb::Movie.translations(22855)

Movie - Similar Movies

Get the similar movies for a specific movie id.

Tmdb::Movie.similar_movies(22855)

Movie - Lists

Get the lists that the movie belongs to.

Tmdb::Movie.lists(22855)

Movie - Changes

Get the changes for a specific movie id.

Tmdb::Movie.changes(22855)

Movie - Credits

Get the credits for a specific movie id.

Tmdb::Movie.credits(22855)

TV

show = Tmdb::TV.detail(1396)

Get the list of popular TV shows. This list refreshes every day.

Tmdb::TV.popular

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.

Tmdb::TV.top_rated

TV - Images

Get the images (posters and backdrops) for a TV series.

@show = Tmdb::TV.images(1396)

Grab Backdrops

@show['backdrops']

Grab Posters

@show['posters']

TV - Cast

Get the cast information about a TV series.

Tmdb::TV.cast(1396)

TV - Crew

Get the crew information about a TV series.

Tmdb::TV.crew(1396)

TV - External IDs

Get the external ids that we have stored for a TV series.

Tmdb::TV.external_ids(1396)

Season

show = Tmdb::Season.detail(1396, 1)

Season - Images

Get the images (posters) that we have stored for a TV season by season number.

@season = Tmdb::Season.images(1396, 1)

Grab Posters

@season['posters']

Season - Cast

Get the cast credits for a TV season by season number.

Tmdb::Season.cast(1396, 1)

Season - Crew

Get the crew credits for a TV season by season number.

Tmdb::Season.crew(1396, 1)

Season - External IDs

Get the external ids that we have stored for a TV season by season number.

Tmdb::Season.external_ids(1396, 1)

Episode

episode = Tmdb::Episode.detail(1396, 1, 1)

Episode - Images

Get the images (episode stills) for a TV episode by combination of a season and episode number.

@episode = Tmdb::Episode.images(1396, 1, 1)

Grab Stills

@episode['stills']

Episode - Cast

Get the TV episode cast credits by combination of season and episode number.

Tmdb::Episode.cast(1396, 1, 1)

Episode - Crew

Get the TV episode crew credits by combination of season and episode number.

Tmdb::Episode.crew(1396, 1, 1)

Episode - External IDs

Get the external ids for a TV episode by comabination of a season and episode number.

Tmdb::Episode.external_ids(1396, 1, 1)

Company

company = Tmdb::Company.detail(1)
company.id => 1
company.description => nil
company.homepage => "http://www.lucasfilm.com"
company.logo_path => "/8rUnVMVZjlmQsJ45UGotDOUznxj.png"
company.name => "Lucasfilm"
company.parent_company => nil

Get the list of movies associated with a particular company.

Tmdb::Company.movies(1)

Collection

collection = Tmdb::Collection.detail(51845)
collection.id => 51845
collection.backdrop_path => "..."
collection.parts => "..."
collection.poster_path => "..."
collection.name => "DC Universe Animated Original Movies"

Get all of the images for a particular collection by collection id.

Tmdb::Collection.images(51845)

Person

person = Tmdb::Person.detail(287)
person.id => 287
person.name => "Brad Pitt"
person.place_of_birth => "Shawnee, Oklahoma, United States"
person.also_known_as => []
person.adult => false
person.biography => "From Wikipedia, the free"..
person.birthday => "1963-12-18"
person.deathday => ""
person.homepage => "http://simplybrad.com/"
person.profile_path => "w8zJQuN7tzlm6FY9mfGKihxp3Cb.jpg"

Get the list of popular people on The Movie Database. This list refreshes every day.

Tmdb::Person.popular

Get the latest person id.

Tmdb::Person.latest

Get the credits for a specific person id.

Tmdb::Person.credits(287)

Get the images for a specific person id.

Tmdb::Person.images(287)

Get the changes for a specific person id.

Tmdb::Person.changes(287)

Genre

genre = Tmdb::Genre.detail(18)
genre.id => 18
genre.name => "Drama"
genre.page => 1
genre.total_pages => 45
genre.total_results => 883
genre.results => [...]
genre.get_page(page_number) => Returns next set of movies.

Get a list of all genres.

Tmdb::Genre.list

Job

Get a list of all jobs.

Tmdb::Job.list

License

themoviedb - A ruby wrapper for the movie database API

Copyright (C) 2016 Ahmet Abdi

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

themoviedb's People

Contributors

ahmetabdi avatar armandofox avatar bitboxer avatar breyten avatar dankimio avatar decioferreira avatar dmcneil avatar druzn3k avatar josem avatar jurgens avatar jzgdev avatar miguelghz avatar nwlyer avatar rectifyer avatar rossnoble avatar tpayet avatar yesmeck avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

themoviedb's Issues

Date for the next episode of a TV show?

Is there a way to get the info when the next TV episode will be aired?

For example, let's say that TV show "foobar" is currently on S04E12, and S04E13 will be aired 20.3.2016. - how to get that date?

Looking at the Tmdb::TV.detail(some_id)['seasons'].last gives air_date, episode_count, id, poster_pathand season_number

Objects in lists

Hello,

I see a (hopefully) improvement for this gem.

There are several entities that have some attributes, like Movie or Genre, but when a list is retrieved from TMDB it's a hash instead of an array of those entities.

Wouldn't be better to have entities in lists too?

There is a case when I see almost necessary: Jobs.

I know it's not implemented yet, but I was going to do it when this idea came to my mind.

A job belongs to a department and has a name, the Job.list method would return something like the following:

{"jobs"=>
  [{"department"=>"Writing",
    "job_list"=> ["Screenplay",
                  "Author",
                   .....
                   "Opera",
                   "Co-Writer"]},
   {"department"=>"Directing",
    "job_list"=> ["Director",
                  "Script Supervisor",
                   "Other",
                   "Layout",
                   "Script Coordinator",
                   "Special Guest Director"]}
...
]}

But we would already have an entity for every element of that list and the user should iterate over that hash, making the method almost useless.

My point here is that the method should return an array of Jobs objects, with the department and the name as set attributes and I would do the same for the rest of entities.

If wish you see this interesenting and if that's the case I could submit a pull request.

Travis can't bundle install due to httparty

I've set up a nice Travis for my project but since I started using themoviedb when I push my changes Travis can't manage to run bundle install --deployment, apparently because of the httparty dependency.

There was a LoadError while loading themoviedb.gemspec: 
cannot load such file -- httparty from
/home/travis/build/jerefrer/opentheatre/vendor/bundle/ruby/2.0.0/bundler/gems/themoviedb-a88d6b607c5e/themoviedb.gemspec:3:in
`<main>'
Does it try to require a relative path? That's been removed in Ruby 1.9.

Any idea why ?

Search for TV episodes

Hi!

I have a little problem with searching for tv shows.
I'm trying to search to shows based on there name. So I'm doing the following:

search = Tmdb::Search.new
search.resource('tv')
search.query('Mad Men')
search.fetch

But the fetch returns nil while searching on the TMDB gives some results.

What am I doing wrong here? Can anybody help?

Thanks for this gem. :)

Set language for request

Is it possible to query the database with the lanuage parameter that is described in the api docs? I want to be able to fetch the german version of the description.

Hashugar

What's the point of using Hashugar? It doesn't look like a mature library.

h1 = { a: 5, b: 6 }.to_hashugar
h2 = { a: 5, b: 6 }.to_hashugar
h1 == h2 # => false

Can't distinguish between nil/invalid API key and failed search

In 0.0.14, attempting to use the API with a nil or invalid API key caused an exception (a weird one, having to do with a failed 'gsub', but at least you knew something was wrong.)

In 0.0.17, the following scenarios give identical results:

  • Call Movie.detail(x) with valid API key, where x is a nonexistent TMDb resource id
  • Call Movie.detail(x) with INVALID API key, where x is a nonexistent TMDB resource id
  • Call Movie.detail(x) with INVALID API key, where x is a VALID existing TMDB resource id
    All three calls return a Movie resource whose attributes are all nil.

This is bad for programmers because you can't distinguish between an "invalid API key" error and an error due to supplying a nonexistent ID.

Return native resources

Some methods like Tmdb::Movie.search return a collection of Tmdb::Movie objects. However, there are ones that return hashes (Tmdb::Movie.popular, Tmdb::Movie.now_playing, etc.). Is there a reason these methods return pure hashes? If not, I can submit a pull request with these changes.

Old version of HTTParty

Does this really need an HTTParty '~> 0.11.0' version specification? It is causing conflicts for me, HTTParty is now up to 0.13.1.

Use OpenStruct for attributes?

OpenStruct

This will allow us to skip the definition of attributes and generate them on the go. It'll make it future-proof in case new attributes are added or existing ones are changed.

saving a original_title to rails database.

I've created a autocomplete searchfield in which users can type a movie title and it will show all the results like this > http://i.imgur.com/Si9Fffv.png

The next thing I want to do is give the user a option to save a movie title to the database. As you can see in the image every result has a "add" button. This is a link with the ID of the movie in it's target. It can be anything like a button or a span etc.

When a user clicks on the add button I want to store the movie title of the movie with that ID in my database.

I've generated a model called movie and a collumn called title. I've also generated a controller called movie and I've created a form field which lets the user type the movie title and then save it to do movie model > title collumn. But this was more for testing. Like I said above I want to save the movie title from a specific ID into my database.

I know how to get the JSON respons from TMDB api,
click

But what I don't know is how to link my "add" button to that response and then grab some data like title or poster url and post it in my database.

Don't test against live data

The tests currently fail because the vote count changed. You should consider changing it to vcr or a similar aproach that replays the answer you got from themoviedb instead of using the real data.

0.0.25 Introduces Breaking Changes

I understand that this gem isn't maintained anymore, but I implore you to reject the 0.0.25 published gem, and replace it with a 0.1.0 version.

The reason is that 0.0.25 introduces a huge breaking change with the API by removing hashuger thus changing the api from:

@movie.backdrops

to

@movie['backdrops']

Bundler has a certain expectation that it can bump the patch version of a gem without expecting any major changes. Most developers have this expectation as well and regularly update their gems this way. By doing this, this would install a version of this gem that would have serious compatibility consequences. If it were 0.1.0, it would not get installed without direct effort by the developer.

Again, I understand that this gem has become unmaintained, but bumping it to a 0.1.0 before doing this would be, in my opinion, a more responsible thing to do.

Jekyll integration

Hello, I'm not a developer but I'd love to use this gem in my Jekyll website, to retrieve movie data and automatically add links to TMDb entries for movies I add to a simple markdown list.

Practically, I'd like the gem to read movie titles from a simple markdown list (or a CSV table) and transform titles to links to their page on TMDb.

Could this be possible?
If yes, how?

(obviously I get that what I ask for is something specific and strictly tied with my needs, nevertheless I may adapt to some similar simpler usage)

Thank you very much and sorry for the dumb question.

Question

No issue here, just wanted to see if you had any ideas on how I might be able to integrate the results from the gem into my application's DB? Trying to reduce load times by avoid excessive calls outside the DB.

Can't get posters/backdrops with no language

Hey,

First, thanks for the recent updates! I got a problem with posters for TV series, and I think it's the same for movies. I'm trying to get some posters for series but the gem does not return anything for some series like Chuck and it seems to be related to the language of the backdrop/poster. For example, The Sopranos has many posters: http://www.themoviedb.org/tv/1398-the-sopranos/posters

But the only one I get is the english one, even if I delete the language config thing in the gem. For Chuck, all the posters on tmdb don't have any language, so I get no poster or even backdrop. the gem returns:

{"backdrops"=>[], "id"=>1404, "posters"=>[]}

When I use the API URI directly, the backdrops/posters are visible: https://api.themoviedb.org/3/tv/1404/images?api_key=xx

Any idea how to fix this?

Thank you very much for you work!

Thread Safe language changing for Requests

I want to make calls in the background using the sidekiq gem so I need a thread-safe way to change the language for single requests. Currently there's no request-wide language setting, only the global Tmdb::Api.language("de") setting which – I believe – is not thread-safe. Or is it?

If not, it would be great to have a thread-safe way of making language-specific requests. E.g. the following two requests could be run at the same time in different threads of sidekiq and I don't want this to result in the wrong languages at the wrong place:

Tmdb::Api.language("de")
Tmdb::Movie.find("batman")
Tmdb::Api.language("fr")
Tmdb::Movie.find("batman")

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.