PHP Class Moinax\TvDb\Client

Author: Jérôme Poskin ([email protected])
Show file Open project: moinax/tvdb Class Usage Examples

Protected Properties

Property Type Description
$apiKey string API key for thetvdb.com
$baseUrl string Base url for TheTVDB
$defaultLanguage string Default language.
$httpClient Moinax\TvDb\Http\HttpClient HttpClient used to query the API.
$languages array Array of available languages
$mirrors array Array of available mirrors

Public Methods

Method Description
__construct ( string $baseUrl, string $apiKey )
fetchBanner ( string $banner ) : string Fetch banner raw jpeg data from banner mirror.
getActors ( integer $serieId ) : array Find all actors related to a serie
getBanners ( integer $serieId ) : string Find all banners related to a serie
getBannersFiltered ( $serieId, $filter ) Find banners that match a filter string Eg: poster or season
getDefaultLanguage ( ) : string Get the default query language.
getEpisode ( $serieId, $season, $episode, $language = null ) : Episode Get a specific episode by season and episode number
getEpisodeByAirDate ( $serieId, $airdate, null $language = null ) : Episode
getEpisodeById ( $episodeId, $language = null ) : Episode Get a specific episode by his id
getLanguage ( string $abbreviation ) : array Get a language information
getMirror ( integer $typeMask = self::MIRROR_TYPE_XML ) : string Get a random mirror from the list of available mirrors
getSerie ( $serieId, $language = null ) : Serie Find a tv serie by the id from thetvdb.com
getSerieByRemoteId ( array $remoteId, string $language = null ) : Serie Find a tv serie by a remote id
getSerieEpisodes ( integer $serieId, string $language = null, string $format = self::FORMAT_XML ) : array Get all episodes for a serie
getSeries ( string $seriesName, string $language = null ) : array Searches for tv serie based on series name
getServerTime ( ) : string Get the server time for further updates
getUpdates ( integer $previousTime ) : array Get updates list based on previous time you got data
removeEmptyIndexes ( array $array ) : array Removes indexes from an array if they are zero length after trimming
setDefaultLanguage ( string $language ) Set the default query language. It must be a valid language code.
setHttpClient ( Moinax\TvDb\Http\HttpClient $client ) Set the HttpClient used to query the API.

Protected Methods

Method Description
fetch ( string $url, array $params = [], string $method = self::GET ) : boolean | string Fetch data with curl
fetchXml ( string $function, array $params = [], string $method = self::GET ) : string Fetches data via curl and returns result
fetchZIP ( string $function, array $params = [], string $method = self::GET, string $file = null ) : string Fetches data via curl and returns result
getLanguages ( ) : SimpleXMLElement Get a list of languages available for the content of the api
getMirrors ( ) : void Get a list of mirrors available to fetchXml the data from the api
getXml ( string $data ) : SimpleXMLElement Convert xml string to SimpleXMLElement

Method Details

__construct() public method

public __construct ( string $baseUrl, string $apiKey )
$baseUrl string Domain name of the api without trailing slash
$apiKey string Api key provided by http://thetvdb.com

fetch() protected method

Fetch data with curl
protected fetch ( string $url, array $params = [], string $method = self::GET ) : boolean | string
$url string
$params array
$method string
return boolean | string

fetchBanner() public method

Fetch banner raw jpeg data from banner mirror.
public fetchBanner ( string $banner ) : string
$banner string the banner to fetch like graphical/79349-g7.jpg
return string raw jpeg data

fetchXml() protected method

Fetches data via curl and returns result
protected fetchXml ( string $function, array $params = [], string $method = self::GET ) : string
$function string The function used to fetch data in xml
$params array
$method string
return string The data

fetchZIP() protected method

Fetches data via curl and returns result
protected fetchZIP ( string $function, array $params = [], string $method = self::GET, string $file = null ) : string
$function string The function used to fetch data in zip
$params array
$method string
$file string The file to extract from the ZIP
return string The data

getActors() public method

Find all actors related to a serie
public getActors ( integer $serieId ) : array
$serieId integer
return array

getBanners() public method

Find all banners related to a serie
public getBanners ( integer $serieId ) : string
$serieId integer
return string

getBannersFiltered() public method

Find banners that match a filter string Eg: poster or season
public getBannersFiltered ( $serieId, $filter )

getDefaultLanguage() public method

Get the default query language.
public getDefaultLanguage ( ) : string
return string

getEpisode() public method

Get a specific episode by season and episode number
public getEpisode ( $serieId, $season, $episode, $language = null ) : Episode
return Episode

getEpisodeByAirDate() public method

public getEpisodeByAirDate ( $serieId, $airdate, null $language = null ) : Episode
$serieId
$airdate
$language null
return Episode

getEpisodeById() public method

Get a specific episode by his id
public getEpisodeById ( $episodeId, $language = null ) : Episode
return Episode

getLanguage() public method

Get a language information
public getLanguage ( string $abbreviation ) : array
$abbreviation string
return array

getLanguages() protected method

Get a list of languages available for the content of the api
protected getLanguages ( ) : SimpleXMLElement
return SimpleXMLElement

getMirror() public method

Get a random mirror from the list of available mirrors
public getMirror ( integer $typeMask = self::MIRROR_TYPE_XML ) : string
$typeMask integer
return string

getMirrors() protected method

Get a list of mirrors available to fetchXml the data from the api
protected getMirrors ( ) : void
return void

getSerie() public method

Find a tv serie by the id from thetvdb.com
public getSerie ( $serieId, $language = null ) : Serie
return Serie A serie object or false if not found

getSerieByRemoteId() public method

Find a tv serie by a remote id
public getSerieByRemoteId ( array $remoteId, string $language = null ) : Serie
$remoteId array
$language string
return Serie

getSerieEpisodes() public method

Get all episodes for a serie
public getSerieEpisodes ( integer $serieId, string $language = null, string $format = self::FORMAT_XML ) : array
$serieId integer
$language string
$format string
return array

getSeries() public method

Searches for tv serie based on series name
public getSeries ( string $seriesName, string $language = null ) : array
$seriesName string
$language string
return array

getServerTime() public method

Get the server time for further updates
public getServerTime ( ) : string
return string

getUpdates() public method

Get updates list based on previous time you got data
public getUpdates ( integer $previousTime ) : array
$previousTime integer
return array

getXml() protected method

Convert xml string to SimpleXMLElement
protected getXml ( string $data ) : SimpleXMLElement
$data string
return SimpleXMLElement

removeEmptyIndexes() public static method

Removes indexes from an array if they are zero length after trimming
public static removeEmptyIndexes ( array $array ) : array
$array array The array to remove empty indexes from
return array An array with all empty indexes removed

setDefaultLanguage() public method

Set the default query language. It must be a valid language code.
public setDefaultLanguage ( string $language )
$language string

setHttpClient() public method

Set the HttpClient used to query the API.
public setHttpClient ( Moinax\TvDb\Http\HttpClient $client )
$client Moinax\TvDb\Http\HttpClient

Property Details

$apiKey protected property

API key for thetvdb.com
protected string $apiKey
return string

$baseUrl protected property

Base url for TheTVDB
protected string $baseUrl
return string

$defaultLanguage protected property

Default language.
protected string $defaultLanguage
return string

$httpClient protected property

HttpClient used to query the API.
protected HttpClient,Moinax\TvDb\Http $httpClient
return Moinax\TvDb\Http\HttpClient

$languages protected property

Array of available languages
protected array $languages
return array

$mirrors protected property

Array of available mirrors
protected array $mirrors
return array