public
Description: Simple to use TVDB (thetvdb.com) API in Python, and automatic TV episode namer

tvdb_api

Note that this wiki isn’t updated very often, so could become outdated if something in tvdb_api changes.. The docstrings are always up to date (they are tested by doctest, so if something no longer works, the unittests will fail). Trust the docstrings, don’t rely on this wiki page!

What is it?

It provides a Python’y interface to the TVDB API ( http://www.thetvdb.com )

Example usage

from tvdb_api import Tvdb
t = Tvdb()
print t['Scrubs'][4][22]['episodename'] # This will print the name of Scrubs episode 22, in season 4
print t['My Name Is Earl'][2][1]['episodename'] # Prints name of episode 1 of season 2
print t['Scrubs'].search('my first', key='episodename')[0]['episodename'] # Prints the first episode whose name contains "my first"

Initialization arguments

Currently there are only two arguments when initializing the tvdb() class: debug and interactive.

Interactive will prompt the user to select a series from a list. It prints out a list in the following format, and gets user input via raw_input() :
1 -> Lost (tvdb id: 73739)
2 -> Lost (2001) (tvdb id: 72906)
3 -> Lost Treasures of NFL Films (tvdb id: 73831)
4 -> Lost Universe (tvdb id: 73181)
5 -> Lost Highway (tvdb id: 74729)
6 -> Lost at Home (tvdb id: 71150)
Enter choice (first number):

The second option, debug, simply shows debugging info (Such as requests URLs, information on “name correction”) to stderr.

Search You can search all episodes of a show, by doing:

results = t['Scrubs'].search('my first', key='episodename')

This returns an array of Episode()s, you can retrieve the first result:

first_result = results[0]

Then retrieve the name of the first result by doing:

first_result['episodename']

Show information

You can retrieve arbitrary on the show, like when it was first aired, the network etc, by doing..

t['Scrubs']['network']
Last edited by dbr, 12 days ago
Versions: