Package: tvdb_api
#tvdb_api[![PyPI][pypi-img]][pypi-link] [![Build Status][travis-img]][travis-link] [![codecov][coverage-img]][coverage-link]tvdb_apiis an easy to use interface to [thetvdb.com][tvdb]It supports Python 2.7, and 3.5 onwardstvnamerhas moved to a separate repository: [github.com/dbr/tvnamer][tvnamer] - it is a utility which usestvdb_apito rename files fromsome.show.s01e03.blah.abc.avitoSome Show - [01x03] - The Episode Name.avi(which works by getting the episode name fromtvdb_api)[tvdb]:http://thetvdb.com[tvnamer]:http://github.com/dbr/tvnamer[travis-link]:https://travis-ci.com/dbr/tvdb_api[travis-img]:https://travis-ci.com/dbr/tvdb_api.svg?branch=master[pypi-link]:https://pypi.org/project/tvdb-api/[pypi-img]:https://img.shields.io/pypi/v/tvdb_api[coverage-link]:https://codecov.io/gh/dbr/tvdb_api[coverage-img]:https://codecov.io/gh/dbr/tvdb_api/branch/master/graph/badge.svg## To installYou can easily installtvdb_apiviapippip install –upgrade tvdb_apiYou may need to use sudo, depending on your setup:sudo pip install –upgrade tvdb_api## Basic usageFirst initialise an instance of theTvdbclass with your API key:import tvdb_api
t = tvdb_api.Tvdb()Note you must specify the apikey argument here, for example:t = Tvdb(apikey=”ENTER YOUR API KEY HERE”) # doctest:+SKIPSeehttps://thetvdb.com/api-informationto register a key.Then to use the API:episode = t[‘My Name Is Earl’][1][3] # get season 1, episode 3 of show
print episode[‘episodename’] # Print episode name## Registering an API keyYou must have an API key from <http://thetvdb.com> in order to use this module.Registering for a key is easy to do and can be done within a few minutes - see the following page for details:<https://thetvdb.com/api-information>Note: Intvdb_apiv2 a default key was included for convenience. However over time this key became very heavily used and this causes problems for TheTVDB.com admins. This old shared key will be deprecated and removed at some point soon.## Advanced usageMost of the documentation is in docstrings. The examples are tested (using doctest) so will always be up to date and working.The docstring forTvdb.__init__lists all initialisation arguments, including support for non-English searches, custom “Select Series” interfaces and enabling the retrieval of banners and extended actor information. You can also override the default API key usingapikey, recommended if you’re usingtvdb_apiin a larger script or application### ExceptionsThere are several exceptions you may catch, these can be imported fromtvdb_api:tvdb_error- this is raised when there is an error communicating with [thetvdb.com][tvdb] (a network error most commonly)tvdb_userabort- raised when a user aborts the Select Series dialog (byctrl+c, or enteringq)tvdb_shownotfound- raised whent[‘show name’]cannot find anythingtvdb_seasonnotfound- raised when the requested series (t[‘show name][99]) does not existtvdb_episodenotfound- raised when the requested episode (t[‘show name][1][99]) does not exist.tvdb_attributenotfound- raised when the requested attribute is not found (t[‘show name’][‘an attribute’],t[‘show name’][1][‘an attribute’], ort['showname'][1][1]['anattribute'])### Series dataAll data exposed by [thetvdb.com][tvdb] is accessible via theShowclass. A Show is retrieved by doing..>>> import tvdb_api
>>> t = tvdb_api.Tvdb()
>>> show = t['scrubs']
>>> type(show)
<class 'tvdb_api.Show'>For example, to find out what network Scrubs is aired:>>> t['scrubs']['network']
u'ABC'The data is stored in an attribute nameddata, within the Show instance:>>> t['scrubs'].data.keys()
['networkid', 'rating', 'airs_dayofweek', 'contentrating', 'seriesname', 'id', 'airs_time', 'network', 'fanart', 'lastupdated', 'actors', 'ratingcount', 'status', 'added', 'poster', 'tms_wanted_old', 'imdb_id', 'genre', 'banner', 'seriesid', 'language', 'zap2it_id', 'addedby', 'firstaired', 'runtime', 'overview']Although each element is also accessible viat[‘scrubs’]for ease-of-use:>>> t['scrubs']['rating']
u'9.0'This is the recommended way of retrieving “one-off” data (for example, if you are only interested in “seriesname”). If you wish to iterate over all data, or check if a particular show has a specific piece of data, use thedataattribute,>>> 'rating' in t['scrubs'].data
True### Banners and actorsSince banners and actors are separate XML files, retrieving them by default is undesirable. If you wish to retrieve banners (and other fanart), use thebannersTvdb initialisation argument:>>> from tvdb_api import Tvdb
>>> t = Tvdb(banners = True)Then access the data using aShow’s_bannerkey:>>> t['scrubs']['_banners'].keys()
['fanart', 'poster', 'series', 'season']The banner data structure will be improved in future versions.Extended actor data is accessible similarly:>>> t = Tvdb(actors = True)
>>> actors = t['scrubs']['_actors']
>>> actors[0]
<Actor "Zach Braff">
>>> actors[0].keys()
['sortorder', 'image', 'role', 'id', 'name']
>>> actors[0]['role']
u'Dr. John Michael "J.D." Dorian'Remember a simple list of actors is accessible via the default Show data:>>> t['scrubs']['actors']
u'|Zach Braff|Donald Faison|Sarah Chalke|Judy Reyes|John C. McGinley|Neil Flynn|Ken Jenkins|Christa Miller|Aloma Wright|Robert Maschio|Sam Lloyd|Travis Schuldt|Johnny Kastl|Heather Graham|Michael Mosley|Kerry Bish\xe9|Dave Franco|Eliza Coupe|'