Sha256: eea600bddba3fc222b9a3e6f5278fc95ff5ad366a7d158ad53b6f99a43724a58

Contents?: true

Size: 828 Bytes

Versions: 1

Compression:

Stored size: 828 Bytes

Contents

module FilmBuff
  class IMDb
    attr_accessor :locale

    include HTTParty
    include HTTParty::Icebox
    cache :store => 'memory', :timeout => 120

    base_uri 'app.imdb.com'
    default_params = {
      "api" => "v1",
      "app_id" => "iphone1_1",
      "timestamp" => Time.now.utc.to_i,
      "sig" => "app1_1"
    }

    def initialize
      @locale = "en_US"
    end

    public
    def find_by_id(imdb_id)
      result = self.class.get('/title/maindetails', :query => {
        :tconst => imdb_id, :locale => @locale
      }).parsed_response
      Title.new(result["data"])
    end

    def find_by_title(title)
      results = self.class.get('/find', :query => {
        :q => title, :locale => @locale
      }).parsed_response
      find_by_id(results["data"]["results"][0]["list"][0]["tconst"])
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
filmbuff-0.1.5 lib/filmbuff/imdb.rb