skip to navigation
skip to content

Not Logged In

easytmdb 0.1.1

A Python wrapper for The Movie Database API v3

A wrapper for The Movie Database v3

easytmdb is a wrapper, written in Python, for The Movie Database (TMDb) API v3. By calling the functions available in easytmdb, you can simplify your code and easily access a vast amount of movie, tv, and cast data. To find out more about The Movie Database API, check out the overview page http://www.themoviedb.org/documentation/api and documentation page http://docs.themoviedb.apiary.io.

Features

  • Tested on Python 2.7.5 and 3.3.3
  • Implements all TMDb methods, including Authentication and Accounts.
  • Implements new TV features.
  • Easy to access data using Python class attributes.
  • Easy to experiment with easytmdb functions inside the Python interpreter.
  • Code tested with unittests, which illustrate the function call syntax.

Installation

You can install easytmdb using one of the following techniques.

  • Use pip:
pip install easytmdb
  • Download the .zip or .tar.gz file from PyPI and install it yourself
  • Download the source from Github and install it yourself

If you install it yourself, also install requests.

API Key

You will need an API key to The Movie Database to access the API. To obtain a key, follow these steps:

  1. Register for and verify an account.
  2. Log into your account.
  3. Select the API section on left side of your account page.
  4. Click on the link to generate a new API key and follow the instructions.

Examples

Once you have the easytmdb package installed and a TMDb API key, you can start to play with the data.

First, import the library and create an instance of a TMDB object.

>>> import easytmdb as tmdb
>>> tmdb.API_KEY = 'YOUR_API_KEY_HERE'

To communicate with The Movie Database API, create an instance of one of the object types, call one of the methods on the instance, and access the instance attributes. Use keys to access the values of attributes that are dictionaries.

>>> movie = tmdb.Movies(603)
>>> movie.info()
>>> movie.title
'The Matrix'
>>> movie.budget
63000000
>>> movie.releases()
>>> for c in movie.countries:
...    if c['iso_3166_1'] == 'US':
...         print(c['certification'])
...
'R'

Let's play with the interface a bit more. Suppose you and your friend are arguing over which movie in the Bourne series was most popular. Your friend says the first in a series is always most popular. You disagree.

>>> search = tmdb.Search()
>>> search.movie({'query': 'The Bourne'})
>>> for s in search.results:
...     print(s['title'], s['id'], s['release_date'], s['popularity'])
...
The Bourne Ultimatum 2503 2007-08-03 55.2447062124256
The Bourne Supremacy 2502 2004-07-23 43.4553609681985
The Bourne Identity 2501 2002-06-06 38.5531563780592
The Bourne Legacy 49040 2012-08-10 9.90635210153143
The Bourne Identity 8677 1988-05-08 1.53988446573129
Bette Bourne: It Goes with the Shoes 179304  0.23

You are correct! Now you claim the producers should be able to make sequels cheaper, based on what they learned from making the first movie. To be fair, you compute the budget per minute of runtime. Your friend disagrees, claiming the producers spend more money trying to out do the previous sequel.

>>> identity = tmdb.Movies(2501)
>>> response = identity.info()
>>> identity.budget, identity.runtime
(60000000, 119)
>>> int(identity.budget/identity.runtime)
504201
>>> supremacy = tmdb.Movies(2502)
>>> response = supremacy.info()
>>> supremacy.budget, supremacy.runtime
(75000000, 108)
>>> int(supremacy.budget/supremacy.runtime)
694444
>>> ultimatum = tmdb.Movies(2503)
>>> response = ultimatum.info()
>>> ultimatum.budget, ultimatum.runtime
(70000000, 115)
>>> int(ultimatum.budget/ultimatum.runtime)
608695

In this case you are both correct. The third movie was cheaper than the second, which was more expensive than the first.

You also can call one of the methods without explicitly instanciating an object.

>>> response = tmdb.Movies(603).info()
>>> response['budget']
63000000

If you use Authentication to access a user Account, be sure to check out https://www.themoviedb.org/documentation/api/sessions.

Acknowledgment

This project is based on tmdbsimple by Celia Oakley.

Changes made:

  1. Use class inheritance instead of nested classes
 
File Type Py Version Uploaded on Size
easytmdb-0.1.1.tar.gz (md5) Source 2014-01-22 12KB
  • Downloads (All Versions):
  • 14 downloads in the last day
  • 78 downloads in the last week
  • 218 downloads in the last month