Giter Club home page Giter Club logo

ruby-tmdb's Introduction

ruby-tmdb3

Build Status

ruby-tmdb3 is an ActiveRecord-style API wrapper for TheMovieDB.org (TMDb). ruby-tmdb3 uses tmdb's API v3 and is designed to streamline common tasks associated with finding information about movies and cast members.

Installation

For ease of use ruby-tmdb3 is packaged as a Rubygem. Installing it is as simple as:

gem install ruby-tmdb3

Compatibility

Ruby 1.8.x & 1.9.x (2.0.x experimental)

Examples

require 'rubygems'
require 'ruby-tmdb3'

# setup your API key
Tmdb.api_key = "t478f8de5776c799de5a"

# setup your default language
Tmdb.default_language = "en"

@movie = TmdbMovie.find(:title => "Iron Man", :limit => 1)
# => <OpenStruct>

@movie.title
# => "Iron Man"

Usage

There are 3 main methods you can use to get information about movies and cast members:

TmdbMovie.find([:id, :imdb, :title, :limit, :expand_results, :language])

Find information about an individual movie, or a set of movies that share a similar title, eg:

TmdbMovie.find(:title => "fight club", :limit => 10, :expand_results => true, :language => "en")

Parameters:

:id
Specifies an individual movie via it's TMDb id
:title
Specifies a query string to look for in the movie titles
:imdb
Specifies an individual movie via it's IMDB id
:limit
Specifies the maximum number of results to be returned
:expand_results
The TMDb API by default returns only partial info for any API method that can return multiple results. When :expand_results is set to true ruby-tmdb3 automatically makes extra API calls to fetch the full information for each item. This can result in *very* slow requests though. If you only need basic information for a search listing then set this to false. Defaults to 'true'.
:language
Allows you to override the default API language on a per-query basis.

You must supply at least one of :id, :title, or :imdb. All other parameters are optional.

TmdbCast.find([:id, :name, :limit, :expand_results, :language])

Find information about an individual cast member, or a set of cast members sharing similar names, eg:

TmdbCast.find( :id => 123, :name => "Brad", :limit => 1, :expand_results => true)
:id
Specifies an individual cast member via their TMDb id
:name
Specifies a query string to look for in the cast names
:limit
See TmdbMovie
:expand_results
See TmdbMovie
language
See TmdbMovie

You must supply at least one of :id or :name. All other parameters are optional.

Usage Examples

Find all movies whose titles match a given string:

@movies = TmdbMovie.find(:title => 'Iron Man')

Find the movie most likely to be associated with a given title:

@movie = TmdbMovie.find(:title => 'Sin City', :limit => 1)

Find a single movie by it's TMDb ID:

@movie = TmdbMovie.find(:id => 187)

Find a single movie by it's IMDB ID:

@movie = TmdbMovie.find(:imdb => 'tt0401792')

Find all cast members whose names match a given string:

@actors = TmdbCast.find(:name => 'Fred')

Find an individual cast member via their TMDb ID:

@actor = TmdbCast.find(:id => 101)

Get the info for a movie in French:

@movie = TmdbMovie.find(:title => 'Sin City', :limit => 1, :language => "fr")

Contributing

ruby-tmdb3 is maintained to work under Ruby 1.8.x & 1.9.x. Please make sure it works under both.

  • Fork the repo.
  • Create a topic branch.
  • Push the topic branch to your fork.
  • Create a pull request.

Item information

To find out more about the information each object offers on retrieved items have a look at the TMDb API Docs. For the most accurate information about the information available have a look at the data directly through ruby-tmdb3 by calling @item.raw_data.inspect

Author & Credits

The whole contributor list can be seen at https://github.com/Irio/ruby-tmdb/graphs/contributors.

Copyright (c) 2012 Irio Irineu Musskopf Junior. Copyright (c) 2010 Aaron Gough, released under the MIT license.

Bitdeli Badge

ruby-tmdb's People

Contributors

aarongough avatar alexhayes avatar bitdeli-chef avatar flink avatar irio avatar maddox avatar mskog avatar oleander avatar romaind 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

ruby-tmdb's Issues

404 errors from API calls

I'm getting a 404 error from every API call I'm trying to make. For example this code:
@movie = TmdbMovie.find(:title => "Iron Man", :limit => 1)

returns this:
RuntimeError: Tmdb API returned status code '404' for URL: 'http://api.themoviedb.org/3/search/movie'

Maybe there is something wrong on my machine, but I saw official API requires Accept: application/json header to be set and I coudn't find it in your source codes. Could it be the reason?

TV Series support

Hey guys,

First, thank you for this amazing gem. We use it to grab some informations about movies for our quiz game called "whatthemovie"(.com) and it works perfectly. TMDB recently added TV series support and 60,000+ series were already imported. A "TV" API is already available and it would be awesome if you could update the gem to handle series!

Apparently they added something to search either a movie or a series with the imdb_id: http://docs.themoviedb.apiary.io/#find

And there are also some API calls exclusively for series: http://docs.themoviedb.apiary.io/#tv

Do you think it's doable?

Thank you again for your work!

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.