NAME
TVDB::API - API to www.thetvdb.com
SYNOPSIS
use TVDB::API;
my $tvdb = TVDB::API::new([[$apikey], $language]);
$tvdb->setApiKey($apikey);
$tvdb->setLang('en');
$tvdb->setUserAgent("TVDB::API/$VERSION");
$tvdb->setBannerPath("/foo/bar/banners");
$tvdb->setCacheDB("$ENV{HOME}/.tvdb.db");
my $hashref = $tvdb->getConf();
my $value = $tvdb->getConf($key);
$tvdb->setConf($key, $value);
$tvdb->setConf({key1=>'value1', key2=>'value2'});
my $hashref = $tvdb->getAvailableMirrors([$nocache]);
$tvdb->setMirrors($mirror, [$banner, [$zip]]);
$tvdb->chooseMirrors([$nocache]);
$tvdb->getAvailableLanguages([$nocache]);
$tvdb->getUpdates([$period]);
my $series_id = $tvdb->getPossibleSeriesId($series_name, [$nocache]);
my $series_id = $tvdb->getSeriesId($series_name, [$nocache]);
my $name = $tvdb->getSeriesName($series_id, [$nocache]);
my $hashref = $tvdb->getSeries($series_name, [$nocache]);
my $hashref = $tvdb->getSeriesAll($series_name, [$nocache]);
my $hashref = $tvdb->getSeriesActors($series_name, [$nocache]);
my $hashref = $tvdb->getSeriesActorsSorted($series_name, [$nocache]);
my $hashref = $tvdb->getSeriesBanners($series_name, $type, $type2, $value, [$nocache]);
my $hashref = $tvdb->getSeriesInfo($series_name, key, [$nocache]);
my $string = $tvdb->getSeriesBanner($series_name, [$buffer, [$nocache]]);
my $string = $tvdb->getSeriesFanart($series_name, [$buffer, [$nocache]]);
my $string = $tvdb->getSeriesPoster($series_name, [$buffer, [$nocache]]);
my $string = $tvdb->getSeriesOverview($series_name, [$nocache]);
my $path = $tvdb->getBanner($banner, [$buffer, [$nocache]]);
my $int = $tvdb->getMaxSeason($series, [$nocache]);
my $hashref = $tvdb->getSeason($series, $season, [$nocache]);
my @picture_names = $tvdb->getSeasonBanners($series, $season, [$nocache]);
my $string = $tvdb->getSeasonBanner($series, $season, [$buffer, [$nocache]]);
my @picture_names = $tvdb->getSeasonBannersWide($series, $season, [$nocache]);
my $string = $tvdb->getSeasonBannerWide($series, $season, [$buffer, [$nocache]]);
my $int = $tvdb->getMaxEpisode($series, $season, [$nocache]);
my $hashref = $tvdb->getEpisode($series, $season, $episode, [$nocache]);
my $hashref = $tvdb->getEpisodeAbs($series, $absEpisode, [$nocache]);
my $hashref = $tvdb->getEpisodeDVD($series, $DVDseason, $DVDepisode, [$nocache]);
my $hashref = $tvdb->getEpisodeId($episodeid, [$nocache]);
my $hashref = $tvdb->getEpisodeByAirDate($series, $airdate, [$nocache]);
my $string = $tvdb->getEpisodeInfo($series, $season, $episode, $info, [$nocache]);
my $string = $tvdb->getEpisodeBanner($series, $season, $episode, [$buffer, [$nocache]]);
my $string = $tvdb->getEpisodeName($series, $season, $episode, [$nocache]);
my $string = $tvdb->getEpisodeOverview($series, $season, $episode, [$nocache]);
my $hashref = $tvdb->getRatingsForUser($userid, $series, [$nocache]);
$tvdb->dumpCache();
DESCRIPTION
This module provides an API to the TVDB database through the new published API.
- $tvdb = TVDB::API::new([APIKEY, [LANGUAGE]])
-
Create a TVDB::API object using
APIKEY
and using a default language ofLANGUAGE
. Both these arguments are optional.New can also be called with a hashref as the first argument.
$tvdb = TVDB::API::new({ apikey => $apikey, lang => 'en', cache => 'filename', banner => 'banner/path', useragent => 'My useragent' });
- setApiKey(APIKEY);
-
Set the
APIKEY
to be used to access the web api for thetvdb.com - setLang(LANGUAGE);
-
Set the
LANGUAGE
to use when downloading data from thetvdb.com - setUserAgent(USERAGENT);
-
Set the
USERAGENT
to be used when downloading information from thetvdb.com - setBannerPath(PATH);
-
Set the path in which to save downloaded banner graphics files.
- setCacheDB("$ENV{HOME}/.tvdb.db");
-
Set the name of the database file to be used to save data from thetvdb.com
- getAvailableMirrors([NOCACHE]);
-
Get the list of mirror sites available from thetvdb.com. It returns a hashref of arrays. If
NOCACHE
is non-zero, then the mirrors are downloaded again even if they are in the cache database already.Returns: { xml => @xml_mirrors, banner => @banner_mirrors, zip => @zip_mirrors, }
- setMirrors(MIRROR, [BANNER, [ZIP]])
-
Set the mirror site(s) to be used to download tv info. If
BANNER
orZIP
or not specified, thenMIRROR
is used instead. - chooseMirrors([NOCACHE])
-
Choose a random mirror from the list of available mirrors. If
NOCACHE
is non-zero, then the mirrors are downloaded again even if they are in the cache database already. - getConf([KEY])
-
Get configurable values by
KEY
. If noKEY
is specified, a hashref of all values is returned. - setConf(KEY, VALUE) or setConf({KEY=>VALUE, ...})
-
Set configurable values by
KEY
/VALUE
pair. If a hashref is passed in, allKEY
/VALUE
pairs in the hashref will be configured.maxSeason => 50, # Maximum allowed season maxEpisode => 50, # Maximum allowed episode minUpdateTime => 3600*6, # Used by getUpdate('now') minBannerTime => 3600*24*7, # Used by getBanner() minEpisodeTime => 3600*24*7, # Used by getEpisode()
- getAvailableLanguages([NOCACHE])
-
Get a list of available languages, and return them in a hashref. If
NOCACHE
is non-zero, then the available languages are downloaded again even if they are in the cache database already. - getUpdates([PERIOD])
-
Get appropriate updates (day/week/month/all) from thetvdb.com based on the specified
PERIOD
. It then downloads updates for series, episodes, and banners which have already been downloaded.day
-
Get the updates for the last 24 hours (86400 seconds).
week
-
Get the updates for the last week (7 days, or 604800 seconds).
month
-
Get the updates for the last month (30 days, or 2592000 seconds).
all
-
Get all updates available.
now
-
Based on the last update performed, determine whether to do a day, week, month or all update.
guess
-
Like
now
, based on the last update performed; determine whether to do a day, week, month or all update. However, if the last update was performed in the last 6 hours (setable asminUpdateTime
with setConf()), do nothing. This is the defaultPERIOD
.
- getPossibleSeriesId(SERIESNAME)
-
Get a list of possible series ids for
SERIESNAME
from thetvtb.com. This will return a hashref of possibilities. - getSeriesId(SERIESNAME, [NOCACHE])
-
Get the series id (an integer) for
SERIESNAME
from thetvtb.com. IfNOCACHE
is non-zero, then the series id is downloaded again even if it is in the cache database already. - getSeriesName(SERIESID, [NOCACHE])
-
Get the series name (a string) for
SERIESID
. IfNOCACHE
is non-zero, then the series name is downloaded again even if it is in the cache database already. - getSeries(SERIESNAME, [NOCACHE])
-
Get the series info for
SERIESNAME
from thetvtb.com, which is returned as a hashref. IfNOCACHE
is non-zero, then the series info is downloaded again even if it is in the cache database already. - getSeriesAll(SERIESNAME, [NOCACHE])
-
Get the series info, and all episodes for
SERIESNAME
from thetvtb.com, which is returned as a hashref. IfNOCACHE
is non-zero, then the series info and episodes are downloaded again even if they are in the cache database already. - getSeriesActors(SERIESNAME, [NOCACHE])
-
Get the actors for
SERIESNAME
from thetvtb.com, which is returned as a hashref. IfNOCACHE
is non-zero, then the list of actors are downloaded again even if they are in the cache database already. - getSeriesActorsSorted(SERIESNAME, [NOCACHE])
-
Get the actors for
SERIESNAME
from thetvtb.com, which is returned as an arrayref sorted by SortOrder. IfNOCACHE
is non-zero, then the list of actors are downloaded again even if they are in the cache database already. - getSeriesBanners(SERIESNAME, TYPE, TYPE2, VALUE, [NOCACHE])
-
Get the banners for
SERIESNAME
from thetvtb.com. Info about the available banners are returned in a hashref. The actual banners can be downloaded individually withgetBanner
(see below). IfNOCACHE
is non-zero, then the list of banners are downloaded again even if they are in the cache database already.if
TYPE
is specified (series, season, poster, or fanart) then only return banners of that type. ifTYPE2
is specified then only return banners of that sub type. IfTYPE
is "series" thenTYPE2
can be "text", "graphical", or "blank". IfTYPE
is "season" thenTYPE2
can be "season", or "seasonwide" andVALUE
specifies the season number. IfTYPE
is "fanart" thenTYPE2
is the desired resolution of the image. - getSeriesInfo(SERIESNAME, KEY, [NOCACHE])
-
Return a string for
KEY
in the hashref forSERIESNAME
. IfNOCACHE
is non-zero, then the series is downloaded again even if it is in the cache database already. - getSeriesBanner(SERIESNAME, [BUFFER, [NOCACHE]])
-
Get the
SERIESNAME
banner from thetvdb.com and save it in theBannerPath
directory. The cached banner is updated viagetUpdates
when appropriate. If aBUFFER
is provided (a scalar reference), the banner (newly downloaded, or from the cache) is loaded into it. IfNOCACHE
is non-zero, then the banner is downloaded again even if it is in theBannerPath
directory already. It will return the path of the banner relative to theBannerPath
directory. - getSeriesFanart(SERIESNAME, [BUFFER, [NOCACHE]])
-
Get the
SERIESNAME
fan art from thetvdb.com and save it in theBannerPath
directory. The cached fan art is updated viagetUpdates
when appropriate. If aBUFFER
is provided (a scalar reference), the fan art (newly downloaded, or from the cache) is loaded into it. IfNOCACHE
is non-zero, then the fan art is downloaded again even if it is in theBannerPath
directory already. It will return the path of the fan art relative to theBannerPath
directory. - getSeriesPoster(SERIESNAME, [BUFFER, [NOCACHE]])
-
Get the
SERIESNAME
poster from thetvdb.com and save it in theBannerPath
directory. The cached poster is updated viagetUpdates
when appropriate. If aBUFFER
is provided (a scalar reference), the poster (newly downloaded, or from the cache) is loaded into it. IfNOCACHE
is non-zero, then the poster is downloaded again even if it is in theBannerPath
directory already. It will return the path of the poster relative to theBannerPath
directory. - getSeriesOverview(SERIESNAME, [NOCACHE])
-
Get the series overview from thetvdb.com and return it as a string. If
NOCACHE
is non-zero, then the banner is downloaded again even if it is in the cache database already. - getBanner(BANNER, [BUFFER, [NOCACHE]])
-
Get the
BANNER
from thetvdb.com and save it in theBannerPath
directory. The cached banner is updated viagetUpdates
when appropriate. If aBUFFER
is provided (a scalar reference), the picture (newly downloaded, or from the cache) is loaded into it. IfNOCACHE
is non-zero, then the banner is downloaded again even if it is in theBannerPath
directory already. It will return the path of the picture relative to theBannerPath
directory. In this case it will just be the same asBANNER
.The
minBannerTime
configuration variable determines the maximum time a banner download failure will be cached. (see getConf()/setConf()). - getMaxSeason(SERIESNAME, [NOCACHE])
-
Return the number of the last season for
SERIESNAME
. IfNOCACHE
is non-zero, then any series info needed to calculate this is downloaded again even if it is in the cache database already. - getSeason(SERIESNAME, SEASON, [NOCACHE])
-
Return a hashref of episodes in
SEASON
forSERIESNAME
. IfNOCACHE
is non-zero, then any episodes needed for this season is downloaded again even if it is in the cache database already.The
maxSeason
configuration variable determines the maximum allowable season (see getConf()/setConf()). - getSeasonBanners(SERIESNAME, SEASON, [NOCACHE])
-
Return an array of banner names for
SEASON
forSERIESNAME
. These names can get used withgetBanner()
to actually download the banner file. IfNOCACHE
is non-zero, then any data needed for this is downloaded again even if it is in the cache database already. - getSeasonBanner(SERIESNAME, SEASON, [BUFFER, [NOCACHE]])
-
Get a random banner for
SEASON
forSERIESNAME
. The cached banner is updated viagetUpdates
when appropriate. If aBUFFER
is provided (a scalar reference), the banner (newly downloaded, or from the cache) is loaded into it. IfNOCACHE
is non-zero, then the banner is downloaded again even if it is in theBannerPath
directory already. It will return the path of the banner relative to theBannerPath
directory. - getSeasonBannersWide(SERIESNAME, SEASON, [NOCACHE])
-
Return an array of wide banner names for
SEASON
forSERIESNAME
. These names can get used withgetBanner()
to actually download the banner file. IfNOCACHE
is non-zero, then any data needed for this is downloaded again even if it is in theBannerPath
directory already. - getSeasonBannerWide(SERIESNAME, SEASON, [BUFFER, [NOCACHE]])
-
Get a random banner for
SEASON
forSERIESNAME
. The cached banner is updated viagetUpdates
when appropriate. If aBUFFER
is provided (a scalar reference), the banner (newly downloaded, or from the cache) is loaded into it. IfNOCACHE
is non-zero, then the banner is downloaded again even if it is in theBannerPath
directory already. It will return the path of the banner relative to theBannerPath
directory. - getMaxEpisode(SERIESNAME, SEASON, [NOCACHE])
-
Return the number episodes in
SEASON
forSERIESNAME
. IfNOCACHE
is non-zero, then any series info needed to calculate this is downloaded again even if it is in the cache database already.The
maxEpisode
configuration variable determines the maximum allowable episode (see getConf()/setConf()). - getEpisode(SERIESNAME, SEASON, EPISODE, [NOCACHE])
-
Return a hashref for the
EPISODE
inSEASON
forSERIESNAME
. IfNOCACHE
is non-zero, then the episode is downloaded again even if it is in the cache database already.The
minEpisodeTime
configuration variable determines the maximum time a episode lookup failure will be cached. (see getConf()/setConf()). - getEpisodeAbs(SERIESNAME, ABSEPISODE, [NOCACHE])
-
Return a hashref for the absolute episode (
ABSEPISODE
) forSERIESNAME
. IfNOCACHE
is non-zero, then the episode is downloaded again even if it is in the cache database already. - getEpisodeDVD(SERIESNAME, SEASON, EPISODE, [NOCACHE])
-
Return a hashref for the
EPISODE
inSEASON
forSERIESNAME
in DVD order. IfNOCACHE
is non-zero, then the episode is downloaded again even if it is in the cache database already. - getEpisodeId(EPISODEID, [NOCACHE])
-
Return a hashref for the episode indicated by
EPISODEID
. IfNOCACHE
is non-zero, then the episode is downloaded again even if it is in the cache database already. - getEpisodeByAirDate(SERIESNAME, AIRDATE [NOCACHE])
-
Return a hashref for the episode in
SERIESNAME
onAIRDATE
.AIRDATE
can be specified as:2008-01-01 2008-1-1 January 1, 2008 1/1/2008
Currently this lookup is not cached. However, if
NOCACHE
is non-zero, then theSERIESNAME
to seriesid lookup is downloaded again. - getEpisodeInfo(SERIESNAME, SEASON, EPISODE, KEY, [NOCACHE])
-
Return a string for
KEY
in the hashref forEPISODE
inSEASON
forSERIESNAME
. IfNOCACHE
is non-zero, then the episode is downloaded again even if it is in the cache database already. - getEpisodeBanner(SERIESNAME, SEASON, EPISODE, [BUFFER, [NOCACHE]])
-
Get the episode banner for
EPISODE
inSEASON
forSERIESNAME
. The cached banner is updated viagetUpdates
when appropriate. If aBUFFER
is provided, the picture (newly downloaded, or from the cache) is loaded into it. IfNOCACHE
is non-zero, then the banner is downloaded again even if it is in theBannerPath
directory already. It will return the path of the picture relative to theBannerPath
directory. - getEpisodeName(SERIESNAME, SEASON, EPISODE, [NOCACHE])
-
Return the episode name for
EPISODE
inSEASON
forSERIESNAME
. IfNOCACHE
is non-zero, then the episode is downloaded again even if it is in the cache database already. - getEpisodeOverview(SERIESNAME, SEASON, EPISODE, [NOCACHE])
-
Return the overview for
EPISODE
inSEASON
forSERIESNAME
. IfNOCACHE
is non-zero, then the episode is downloaded again even if it is in the cache database already. - getRatingsForUser(USERID, SERIESNAME, [NOCACHE])
-
Get the series ratings for
USERID
. IfSERIESNAME
is specified, the user/community ratings for the series and its episodes are returned in a hashref. IfSERIESNAME
is not specified, then all the series rated by the <USERID> will be returned in a hashref. These lookups are not cached. - dumpCache()
-
Dump the cache database with Dumper to stdout.
EXAMPLE
use Data::Dumper;
use TVDB::API;
my $episode = $tvdb->getEpisode('Lost', 3, 5);
print Dumper($episode);
Produces:
$episode = {
'lastupdated' => '1219734325',
'EpisodeName' => 'The Cost of Living',
'seasonid' => '16270',
'Overview' => 'A delirious Eko wrestles with past demons; some of the castaways go to the Pearl station to find a computerthey can use to locate Jack, Kate and Sawyer; Jack does not know who to trust when two of the Others are at odds with each other.',
'filename' => 'episodes/73739-308051.jpg',
'EpisodeNumber' => '5',
'Language' => 'en',
'Combined_season' => '3',
'FirstAired' => '2006-11-01',
'seriesid' => '73739',
'Director' => 'Jack Bender',
'SeasonNumber' => '3',
'Writer' => 'Monica Owusu-Breen, Alison Schapker',
'GuestStars' => '|Olalekan Obileye| Kolawole Obileye Junior| Alicia Young| Aisha Hinds| Lawrence Jones| Ariston Green| Michael Robinson| Jermaine|',
'Combined_episodenumber' => '5'
};
AUTHOR
Behan Webster <behanw@websterwood.com>
COPYRIGHT
Copyright (c) 2008 Behan Webster. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.