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->getAvailableMirrors([$nocache]);
$tvdb->setMirrors($mirror, [$banner, [$zip]]);
$tvdb->chooseMirrors([$nocache]);
$tvdb->getAvailableLanguages([$nocache]);
$tvdb->getUpdates([$period]);
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->getSeriesBanners($series_name, $type, $type2, $value, [$nocache]);
my $hashref = $tvdb->getSeriesInfo($series_name, [$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->getEpisodeId($episodeid, [$nocache]);
my $string = $tvdb->getEpisodeInfo($series, $season, $episode, $info, [$nocache]);
my $string = $tvdb->getEpisodeBanner($series, $season, $episode, [$nocache]);
my $string = $tvdb->getEpisodeName($series, $season, $episode, [$nocache]);
my $string = $tvdb->getEpisodeOverview($series, $season, $episode, [$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
APIKEYand using a default language ofLANGUAGE. Both these arguments are optional. - setApiKey(APIKEY);
-
Set the
APIKEYto be used to access the web api for thetvdb.com - setLang(LANGUAGE);
-
Set the
LANGUAGEto use when downloading data from thetvdb.com - setUserAgent(USERAGENT);
-
Set the
USERAGENTto 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
NOCACHEis 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
BANNERorZIPor not specified, thenMIRRORis used instead. - chooseMirrors([NOCACHE]);
-
Choose a random mirror from the list of available mirrors. If
NOCACHEis non-zero, then the mirrors are downloaded again even if they are in the cache database already. - getAvailableLanguages([NOCACHE]);
-
Get a list of available languages, and return them in a hashref. If
NOCACHEis 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, do nothing. This is the defaultPERIOD
If
NOWAITis non-zero, then get updates despite having checked recently. - getSeriesId(SERIESNAME, [NOCACHE]);
-
Get the series id (an integer) for
SERIESNAMEfrom thetvtb.com. IfNOCACHEis 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. IfNOCACHEis 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
SERIESNAMEfrom thetvtb.com, which is returned as a hashref. IfNOCACHEis 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
SERIESNAMEfrom thetvtb.com, which is returned as a hashref. IfNOCACHEis 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
SERIESNAMEfrom thetvtb.com, which is returned as a hashref. IfNOCACHEis 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
SERIESNAMEfrom thetvtb.com. Info about the available banners are returned in a hashref. The actual banners can be downloaded individually withgetBanner(see below). IfNOCACHEis non-zero, then the list of banners are downloaded again even if they are in the cache database already.if
TYPEis specified (series, season, poster, or fanart) then only return banners of that type. ifTYPE2is specified then only return banners of that sub type. IfTYPEis "series" thenTYPE2can be "text", "graphical", or "blank". IfTYPEis "season" thenTYPE2can be "season", or "seasonwide" andVALUEspecifies the season number. IfTYPEis "fanart" thenTYPE2is the desired resolution of the image. - getSeriesInfo(SERIESNAME, KEY, [NOCACHE]);
-
Return a string for
KEYin the hashref forSERIESNAME. IfNOCACHEis non-zero, then the series is downloaded again even if it is in the cache database already. - getSeriesBanner(SERIESNAME, [BUFFER, [NOCACHE]]);
-
Get the
SERIESNAMEbanner from thetvdb.com and save it in theBannerPathdirectory. The cached banner is updated viagetUpdateswhen appropriate. If aBUFFERis provided (a scalar reference), the banner (newly downloaded, or from the cache) is loaded into it. IfNOCACHEis non-zero, then the banner is downloaded again even if it is in theBannerPathdirectory already. It will return the path of the banner relative to theBannerPathdirectory. - getSeriesFanart(SERIESNAME, [BUFFER, [NOCACHE]]);
-
Get the
SERIESNAMEfan art from thetvdb.com and save it in theBannerPathdirectory. The cached fan art is updated viagetUpdateswhen appropriate. If aBUFFERis provided (a scalar reference), the fan art (newly downloaded, or from the cache) is loaded into it. IfNOCACHEis non-zero, then the fan art is downloaded again even if it is in theBannerPathdirectory already. It will return the path of the fan art relative to theBannerPathdirectory. - getSeriesPoster(SERIESNAME, [BUFFER, [NOCACHE]]);
-
Get the
SERIESNAMEposter from thetvdb.com and save it in theBannerPathdirectory. The cached poster is updated viagetUpdateswhen appropriate. If aBUFFERis provided (a scalar reference), the poster (newly downloaded, or from the cache) is loaded into it. IfNOCACHEis non-zero, then the poster is downloaded again even if it is in theBannerPathdirectory already. It will return the path of the poster relative to theBannerPathdirectory. - getSeriesOverview(SERIESNAME, [NOCACHE]);
-
Get the series overview from thetvdb.com and return it as a string. If
NOCACHEis non-zero, then the banner is downloaded again even if it is in the cache database already. - getBanner(BANNER, [BUFFER, [NOCACHE]]);
-
Get the
BANNERfrom thetvdb.com and save it in theBannerPathdirectory. The cached banner is updated viagetUpdateswhen appropriate. If aBUFFERis provided (a scalar reference), the picture (newly downloaded, or from the cache) is loaded into it. IfNOCACHEis non-zero, then the banner is downloaded again even if it is in theBannerPathdirectory already. It will return the path of the picture relative to theBannerPathdirectory. In this case it will just be the same asBANNER. - getMaxSeason(SERIESNAME, [NOCACHE]);
-
Return the number of the last season for
SERIESNAME. IfNOCACHEis 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
SEASONforSERIESNAME. IfNOCACHEis non-zero, then any episodes needed for this season is downloaded again even if it is in the cache database already. - getSeasonBanners(SERIESNAME, SEASON, [NOCACHE]);
-
Return an array of banner names for
SEASONforSERIESNAME. These names can get used withgetBanner()to actually download the banner file. IfNOCACHEis 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
SEASONforSERIESNAME. The cached banner is updated viagetUpdateswhen appropriate. If aBUFFERis provided (a scalar reference), the banner (newly downloaded, or from the cache) is loaded into it. IfNOCACHEis non-zero, then the banner is downloaded again even if it is in theBannerPathdirectory already. It will return the path of the banner relative to theBannerPathdirectory. - getSeasonBannersWide(SERIESNAME, SEASON, [NOCACHE]);
-
Return an array of wide banner names for
SEASONforSERIESNAME. These names can get used withgetBanner()to actually download the banner file. IfNOCACHEis non-zero, then any data needed for this is downloaded again even if it is in theBannerPathdirectory already. - getSeasonBannerWide(SERIESNAME, SEASON, [BUFFER, [NOCACHE]]);
-
Get a random banner for
SEASONforSERIESNAME. The cached banner is updated viagetUpdateswhen appropriate. If aBUFFERis provided (a scalar reference), the banner (newly downloaded, or from the cache) is loaded into it. IfNOCACHEis non-zero, then the banner is downloaded again even if it is in theBannerPathdirectory already. It will return the path of the banner relative to theBannerPathdirectory. - getMaxEpisode(SERIESNAME, SEASON, [NOCACHE]);
-
Return the number episodes in
SEASONforSERIESNAME. IfNOCACHEis non-zero, then any series info needed to calculate this is downloaded again even if it is in the cache database already. - getEpisode(SERIESNAME, SEASON, EPISODE, [NOCACHE]);
-
Return a hashref for the
EPISODEinSEASONforSERIESNAME. IfNOCACHEis 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. IfNOCACHEis non-zero, then the episode is downloaded again even if it is in the cache database already. - getEpisodeInfo(SERIESNAME, SEASON, EPISODE, KEY, [NOCACHE]);
-
Return a string for
KEYin the hashref forEPISODEinSEASONforSERIESNAME. IfNOCACHEis 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
EPISODEinSEASONforSERIESNAME. The cached banner is updated viagetUpdateswhen appropriate. If aBUFFERis provided, the picture (newly downloaded, or from the cache) is loaded into it. IfNOCACHEis non-zero, then the banner is downloaded again even if it is in theBannerPathdirectory already. It will return the path of the picture relative to theBannerPathdirectory. - getEpisodeName(SERIESNAME, SEASON, EPISODE, [NOCACHE]);
-
Return the episode name for
EPISODEinSEASONforSERIESNAME. IfNOCACHEis 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
EPISODEinSEASONforSERIESNAME. IfNOCACHEis non-zero, then the episode is downloaded again even if it is in the cache database already. - dumpCache()
-
Dump the cache database with Dumper to stdout.
EXAMPLE
my $episode = $tvdb->getEpisode('Lost', 3, 5); print Dumper($episode);
$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<gt>
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.