Add the following code to your project's shard.yml under:
to use in production
- OR -
development_dependencies to use in development
A Crystal wrapper for the The Movie Database API.
Add this lines to your
dependencies: tmdb: github: mmacia/tmdb.cr branch: master
shards install from your project.
You have to provide your API key like this:
Tmdb.configure do |conf| conf.api_key = "secret" conf.default_language = "en" end
You can also set the API key in environment variable
TMDB_API_KEY. The value
of this variable has higher precedence.
$ export TMDB_API_KEY='secret'
The default language is english, but you can temporarily override the global language for a single request by specifying it as an additional parameter:
# example Tmdb::Search.movies("terminator", language: "es")
You can save a few API calls activating the cache:
Tmdb.configure do |conf| conf.cache = Tmdb::FileCache.new("/tmp/tmdb", 10_000) end
If you active cache, all methods will be using it. Sometimes you want to get
fresh data for some particular requests: you can pass the
skip_cache: true to
movies = Tmdb::Movie.popular skip_cache: true
Paginated resources are managed by
LazyIterator(T) class. This acts as a
infinite iterator, you just have to call
#map or whatever
enumerable method to acces to the whole collection without worrying about
# example movies = Tmdb::Search.movies("terminator") pp movies.total_items movies.each do |m| pp m.original_title end
Get the movie information for specific movie ID.
Tmdb::Movie.detail 24 Tmdb::Movie.detail 24, language: "es"
Search movies by title.
Search movies by title and release year.
Tmdb::Search.movies "terminator", year: 1984
Get the alternative titles for a specific movie.
movie = Tmdb::Movie.detail 24 movie.alternative_titles country: "es"
Get the cast for a specific movie ID.
movie = Tmdb::Movie.detail 24 movie.cast language: "it"
Get the crew for a specific movie ID.
movie = Tmdb::Movie.detail 24 movie.cast language: "de"
Get the images (posters and backdrops) for a specific movie ID.
movie = Tmdb::Movie.detail 24 movie.images
Get the plot keywords for a specific movie ID.
movie = Tmdb::Movie.detail 24 movie.keywords
Get the release trailers for a specific movie ID.
movie = Tmdb::Movie.detail 24 movie.videos
Get the release dates by country for a specific movie ID.
movie = Tmdb::Movie.detail 24 movie.release_dates
Get the list of upcoming movies. This list refreshes every day.
You can get the upcoming movie for a region.
Tmdb::Movie.upcoming region: "pt"
Get the basic person information for a specific person ID.
Seach for people by name.
Gets a list of popular people. This list refreshes every day.
All endpoints available are those listed in The Movie Database API documentation.
git checkout -b my-new-feature)
git commit -am 'Add some feature')
git push origin my-new-feature)