Project

neo-tmdb

0.0
Repository is archived
No commit activity in last 3 years
No release in over 3 years
A wrapper for the v3 TMDb API from www.themoviedb.org
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 0.4
~> 1.2
~> 2.10
~> 2.2
~> 1.8

Runtime

~> 0.8.0
 Project Readme

Neo TMDb

Dependency Status

Neo TMDb is a Ruby wrapper for the v3 TMDb API from www.themoviedb.org. It provides read-only access with caching and fault tolerance.

Use

Currently you can find people by their TMDb id or search for people.

require 'neo-tmdb'

TMDb.configure do |config|
  # You must configure this library with a TMDb API key before you can use it.
  config.api_key = 'my-tmdb-api-key-here'
end

person = TMDb::Person.find(6384)
puts "#{person.name}, born #{person.birthday} in #{person.place_of_birth}"
# => Keanu Reeves, born 1964-09-02 in Beirut, Lebanon

smallest = TMDb.configuration.image_profile_sizes.first
puts person.profile_image_url(smallest)
# => http://cf2.imgobject.com/t/p/w45/jmjeALlAVaPB8SonLR3qBN5myjc.jpg

# Note: Only the first 20 results are returned.
people = TMDb::Person.where(:name => 'Reeves')
people.each do |person|
  # Note: Only attributes available in the search API will be populated here.
  puts "#{person.name} has TMDb id #{person.id}"
end

Configure caching

You can configure caching so that duplicate requests for the same person are read from the cache rather than directly from the TMDb servers. This helps improve the performance of you application but also prevents it from exceeding the API request limits on the TMDb servers.

require 'active_support'
require 'benchmark'
require 'neo-tmdb'

TMDb.configure do |config|
  config.api_key = 'my-tmdb-api-key-here'
  # You should configure your cache to expire entries after an appropriate
  # period. Note that MemoryStore may not be the best choice for your
  # application.
  config.cache = ActiveSupport::Cache::MemoryStore.new
end

# Note in the following how the first request takes considerable longer than
# the subsequent cached requests.
100.times do |n|
  Benchmark.benchmark('find ') do |b|
    b.report(n.to_s) do
      person = TMDb::Person.find(6384)
      puts "  #{person.name} load #{n}"
    end
  end
end

You can use any cache that implements ActiveSupport's Cache interface.

Documentation

Further documentation can be found in the feature files and on rdoc.info.

Contribute

  • Source hosted on GitHub.
  • Report issues on GitHub Issues.
  • Pull requests are very welcome! Please include scenario and spec coverage for every patch and create a topic branch for every separate change you make.
  • Tests are run by the defaults rake task.

Copyright

See LICENSE for details.