Coder Social home page Coder Social logo

rottentomatoes's Introduction

rottentomatoes

rottentomatoes is an ActiveRecord-style API wrapper for RottenTomatoes.com. rottentomatoes is designed to make common tasks much easier than they would be if dealing directly with the URL based API.

Installation

gem install rottentomatoes

Example

require 'rubygems'
require 'rottentomatoes'
include RottenTomatoes

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

@movie = RottenMovie.find(:title => "Fight Club", :limit => 1)
# => <OpenStruct>

@movie = RottenMovie.find(:imdb => 137523)
# => <OpenStruct>

@movie.title
# => "Fight Club"

@movie.ratings.critics_score
# => 81

@movie.synopsis
# => "An office employee and a soap salesman build a global organization to help vent male aggression."

Usage

RottenTomatoes provides two main object that you will use to query the API.

RottenMovie
RottenList

These objects provide access to movies and lists of movies respectively.

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

RottenMovie.find(:id => 123, :title => "Fight Club", :limit => 10, :expand_results => true)
:id

specifies an individual movie via it’s RottenTomatoes id

:imdb

specifies an individual movie via it’s IMDb id

:title

specifies a query string to look for in the movie titles

:limit

specifies the maximum number of results to be returned

:expand_results

The RottenTomatoes API by default returns only partial info for any API method that can return multiple results, or single movie lookups. When :expand_results is set to true rottentomatoes automatically makes extra API calls to fetch the full information for each item, such as the full cast and reviews. This can result in very slow requests though. If you need extra information for a search listing then set this to true. Defaults to ‘false’. On average the overhead of the extra lookups takes 4x longer to return info.

RottenList.find(:type => "upcoming", :limit => 10, :expand_results => true)
:type

specifies a list type to retrieve. Valid options are ‘box_office’, ‘in_theaters’, ‘opening’, ‘upcoming’, ‘new_releases’, ‘top_rentals’.

:limit

see RottenMovie

:expand_results

see RottenMovie

Usage Examples

Find all movies whose titles match a given string:

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

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

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

Find a single movie by its RottenTomatoes ID:

@movie = RottenMovie.find(:id => 13153)

Find a single movie by its IMDb ID:

@movie = RottenMovie.find(:imdb => 137523)

Find a single movie and all associated information

@movie = RottenMovie.find(:title => 'Fight Club', :expand_results => true, :limit => 1)

Find movies that are playing in theatres

@movie = RottenList.find(:type => 'in_theaters')

Item information

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

Note on Patches/Pull Requests

  • Fork the project.

  • Make your feature addition or bug fix.

  • Add tests for it. This is important so I don’t break it in a future version unintentionally.

  • Commit, do not mess with rakefile, version, or history.

  • Send me a pull request.

Author & Credits

Author

Nicholas Munson

Credits

Aaron Gough

Copyright © 2011 Nicholas Munson (nmunson.com), released under the MIT license

rottentomatoes's People

Contributors

nmunson avatar thedom avatar mesutcan avatar

Watchers

 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.