Giter Club home page Giter Club logo

ruby-tmdb's Introduction

ruby-tmdb

ruby-tmdb is an ActiveRecord-style API wrapper for TheMovieDB.org (TMDb). ruby-tmdb is designed to make common tasks much easier than they would be if dealing directly with the URL based API.

Installation

gem install ruby-tmdb

Example

require 'rubygems'
require 'ruby-tmdb'

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

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

@movie.name
# => "Iron Man"

@movie.posters.length
# => 12

@movie.posters.first.data
# => [binary blob representing JPEG]

Usage

ruby-tmdb provides 2 main objects that you will use to query the API

TmdbMovie
TmdbCast

These objects provide access to movie and cast listing respectively.

Each object provides a find() method which accepts a number of options:

TmdbMovie.find(:id => 123, :title => "fight club", :imdb => 'tt0401792', :limit => 10, :expand_results => true)
: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 idividual 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-tmdb 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’.

TmdbCast.find( :id => 123, :name => "Brad", :limit => 1, :expand_results => true)
:id

specifies an idividual 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

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)

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-tmdb by calling @item.raw_data.inspect

Author & Credits

Author

Aaron Gough

Copyright © 2010 Aaron Gough (thingsaaronmade.com), released under the MIT license

ruby-tmdb's People

Contributors

aarongough avatar niuage avatar

Stargazers

 avatar

Watchers

 avatar James Cloos avatar

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.