mirror of
https://github.com/Yetangitu/ampache
synced 2025-10-03 09:49:30 +02:00
Add art on Videos
Add videos support to Subsonic and UPnP APIs Update Tmdb module
This commit is contained in:
parent
3fc08b17d4
commit
d842ebbb00
246 changed files with 5530 additions and 2127 deletions
|
@ -380,24 +380,16 @@ notify = "true"
|
|||
; methods simply leave it out. DB should be left as the first
|
||||
; method unless you want it to overwrite what's already in the
|
||||
; database
|
||||
; POSSIBLE VALUES: db tags folder amazon lastfm musicbrainz google
|
||||
; POSSIBLE VALUES (builtins): db tags folder lastfm musicbrainz google
|
||||
; POSSIBLE VALUES (plugins): amazon
|
||||
; DEFAULT: db,tags,folder,musicbrainz,lastfm,google
|
||||
art_order = "db,tags,folder,musicbrainz,lastfm,google"
|
||||
|
||||
; Amazon Developer Key
|
||||
; These are needed in order to actually use the amazon album art
|
||||
; Your public key is your 'Access Key ID'
|
||||
; Your private key is your 'Secret Access Key'
|
||||
; DEFAULT: false
|
||||
;amazon_developer_public_key = ""
|
||||
;amazon_developer_private_key = ""
|
||||
;amazon_developer_associate_tag = ""
|
||||
|
||||
; Recommendations
|
||||
; Set this to true to enable display of similar artists or albums
|
||||
; while browsing. Requires Last.FM.
|
||||
; DEFAULT: false
|
||||
;show_similar = "false"
|
||||
show_similar = "true"
|
||||
|
||||
; Concerts
|
||||
; Set this to true to enable display of artist concerts
|
||||
|
@ -407,14 +399,14 @@ art_order = "db,tags,folder,musicbrainz,lastfm,google"
|
|||
|
||||
; Last.FM API Key
|
||||
; Set this to your Last.FM api key to actually use Last.FM for
|
||||
; recommendations.
|
||||
;lastfm_api_key = ""
|
||||
; recommendations and metadata.
|
||||
lastfm_api_key = "d5df942424c71b754e54ce1832505ae2"
|
||||
|
||||
; Wanted
|
||||
; Set this to true to enable display missing albums and the
|
||||
; possibility for users to mark it as wanted.
|
||||
; DEFAULT: false
|
||||
;wanted = "false"
|
||||
wanted = "true"
|
||||
|
||||
; Wanted types
|
||||
; Set the allowed types of wanted releases (album,compilation,single,ep,live,remix,promotion,official)
|
||||
|
@ -441,32 +433,6 @@ wanted_types = "album,official"
|
|||
; DEFAULT: determined automatically
|
||||
;websocket_address = "ws://localhost:8100"
|
||||
|
||||
; Amazon base urls
|
||||
; An array of Amazon sites to search.
|
||||
; NOTE: This will search each of these sites in turn so don't expect it
|
||||
; to be lightning fast!
|
||||
; It is strongly recommended that only one of these is selected at any
|
||||
; one time
|
||||
; POSSIBLE VALUES:
|
||||
; http://webservices.amazon.com
|
||||
; http://webservices.amazon.co.uk
|
||||
; http://webservices.amazon.de
|
||||
; http://webservices.amazon.co.jp
|
||||
; http://webservices.amazon.fr
|
||||
; http://webservices.amazon.ca
|
||||
; Default: http://webservices.amazon.com
|
||||
amazon_base_urls = "http://webservices.amazon.com"
|
||||
|
||||
; max_amazon_results_pages
|
||||
; The maximum number of results pages to pull from EACH amazon site
|
||||
; NOTE: The art search pages through the results returned by your search
|
||||
; up to this number of pages. As with the base_urls above, this is going
|
||||
; to take more time, the more pages you ask it to process.
|
||||
; Of course a good search will return only a few matches anyway.
|
||||
; It is strongly recommended that you do _not_ change this value
|
||||
; DEFAULT: 1 page (10 items)
|
||||
max_amazon_results_pages = 1
|
||||
|
||||
; Debug
|
||||
; If this is enabled Ampache will write debugging information to the log file
|
||||
; DEFAULT: false
|
||||
|
|
29
image.php
29
image.php
|
@ -74,6 +74,11 @@ switch ($_GET['thumb']) {
|
|||
$size['height'] = 32;
|
||||
$size['width'] = 32;
|
||||
break;
|
||||
case '6':
|
||||
/* Video browsing size */
|
||||
$size['height'] = 150;
|
||||
$size['width'] = 100;
|
||||
break;
|
||||
default:
|
||||
$size['height'] = '275';
|
||||
$size['width'] = '275';
|
||||
|
@ -103,10 +108,10 @@ if (isset($_GET['type'])) {
|
|||
}
|
||||
}
|
||||
if (!$typeManaged) {
|
||||
$media = new $type($_GET['id']);
|
||||
$filename = $media->name;
|
||||
$item = new $type($_GET['object_id']);
|
||||
$filename = $item->name ?: $item->title;
|
||||
|
||||
$art = new Art($media->id,$type);
|
||||
$art = new Art($item->id, $type);
|
||||
$art->get_db();
|
||||
$etag = $art->id;
|
||||
|
||||
|
@ -126,10 +131,20 @@ if (!$typeManaged) {
|
|||
}
|
||||
|
||||
if (!$art->raw_mime) {
|
||||
$mime = 'image/jpeg';
|
||||
$image = file_get_contents(AmpConfig::get('prefix') .
|
||||
AmpConfig::get('theme_path') .
|
||||
'/images/blankalbum.jpg');
|
||||
$defaultimg = AmpConfig::get('prefix') . AmpConfig::get('theme_path') . '/images/';
|
||||
switch ($type) {
|
||||
case 'video':
|
||||
case 'tvshow':
|
||||
case 'tvshow_season':
|
||||
$mime = 'image/png';
|
||||
$defaultimg .= "blankmovie.png";
|
||||
break;
|
||||
default:
|
||||
$mime = 'image/jpeg';
|
||||
$defaultimg .= "blankalbum.jpg";
|
||||
break;
|
||||
}
|
||||
$image = file_get_contents($defaultimg);
|
||||
} else {
|
||||
if ($_GET['thumb']) {
|
||||
$thumb_data = $art->get_thumb($size);
|
||||
|
|
|
@ -135,6 +135,8 @@ class Art extends database_object
|
|||
case 'artist':
|
||||
case 'video':
|
||||
case 'user':
|
||||
case 'tvshow':
|
||||
case 'tvshow_season':
|
||||
return $type;
|
||||
default:
|
||||
return 'album';
|
||||
|
@ -246,6 +248,27 @@ class Art extends database_object
|
|||
|
||||
} // get_db
|
||||
|
||||
public static function has_db($object_id, $object_type)
|
||||
{
|
||||
$sql = "SELECT COUNT(`id`) AS `nb_img` FROM `image` WHERE `object_type` = ? AND `object_id` = ?";
|
||||
$db_results = Dba::read($sql, array($object_type, $object_id));
|
||||
$nb_img = 0;
|
||||
if ($results = Dba::fetch_assoc($db_results)) {
|
||||
$nb_img = $results['nb_img'];
|
||||
}
|
||||
|
||||
return ($nb_img > 0);
|
||||
}
|
||||
|
||||
public function insert_url($url)
|
||||
{
|
||||
debug_event('art', 'Insert art from url ' . $url, '5');
|
||||
$image = Art::get_from_source(array('url' => $url), $this->type);
|
||||
$rurl = pathinfo($url);
|
||||
$mime = "image/" . $rurl['extension'];
|
||||
$this->insert($image, $mime);
|
||||
}
|
||||
|
||||
/**
|
||||
* insert
|
||||
* This takes the string representation of an image and inserts it into
|
||||
|
@ -554,9 +577,9 @@ class Art extends database_object
|
|||
if (empty($extension)) {
|
||||
$extension = 'jpg';
|
||||
}
|
||||
$url = AmpConfig::get('web_path') . '/play/art/' . $sid . '/' . scrub_out($uid) . '/thumb.' . $extension;
|
||||
$url = AmpConfig::get('web_path') . '/play/art/' . $sid . '/' . scrub_out($type) . '/' . scrub_out($uid) . '/thumb.' . $extension;
|
||||
} else {
|
||||
$url = AmpConfig::get('web_path') . '/image.php?id=' . scrub_out($uid) . '&object_type=' . scrub_out($type) . '&auth=' . $sid;
|
||||
$url = AmpConfig::get('web_path') . '/image.php?object_id=' . scrub_out($uid) . '&object_type=' . scrub_out($type) . '&auth=' . $sid;
|
||||
if (!empty($extension)) {
|
||||
$name = 'art.' . $extension;
|
||||
$url .= '&name=' . $name;
|
||||
|
@ -592,15 +615,51 @@ class Art extends database_object
|
|||
// Define vars
|
||||
$results = array();
|
||||
|
||||
switch ($this->type) {
|
||||
case 'album':
|
||||
$allowed_methods = array('db','lastfm','folder','amazon','google','musicbrainz','tags');
|
||||
break;
|
||||
case 'artist':
|
||||
case 'video':
|
||||
default:
|
||||
$allowed_methods = array();
|
||||
break;
|
||||
if (count($options) == 0) {
|
||||
switch ($this->type) {
|
||||
case 'album':
|
||||
$album = new Album($this->uid);
|
||||
$album->format();
|
||||
$options['artist'] = $album->f_artist;
|
||||
$options['album'] = $album->f_name;
|
||||
$options['keyword'] = $options['artist'] . ' ' . $options['album'];
|
||||
break;
|
||||
case 'artist':
|
||||
$artist = new Artist($this->uid);
|
||||
$artist->format();
|
||||
$options['artist'] = $album->f_artist;
|
||||
$options['keyword'] = $options['artist'];
|
||||
break;
|
||||
case 'tvshow':
|
||||
$tvshow = new TVShow($this->uid);
|
||||
$tvshow->format();
|
||||
$options['tvshow'] = $tvshow->f_name;
|
||||
$options['keyword'] = $options['tvshow'];
|
||||
break;
|
||||
case 'tvshow_season':
|
||||
$season = new TVShow_Season($this->uid);
|
||||
$season->format();
|
||||
$options['tvshow'] = $season->f_tvshow;
|
||||
$options['tvshow_season'] = $season->f_name;
|
||||
$options['keyword'] = $options['tvshow'];
|
||||
break;
|
||||
case 'tvshow_episode':
|
||||
$video = new TVShow_Episode($this->uid);
|
||||
$video->format();
|
||||
$options['tvshow'] = $video->f_tvshow;
|
||||
$options['tvshow_season'] = $video->f_tvshow_season;
|
||||
$options['tvshow_episode'] = $video->episode_number;
|
||||
$options['keyword'] = $options['tvshow'] . " " . $video->f_title;
|
||||
break;
|
||||
case 'video':
|
||||
case 'clip':
|
||||
case 'movie':
|
||||
case 'personal_video':
|
||||
$video = new Video($this->uid);
|
||||
$video->format();
|
||||
$options['keyword'] = $video->f_title;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$config = AmpConfig::get('art_order');
|
||||
|
@ -617,25 +676,31 @@ class Art extends database_object
|
|||
|
||||
debug_event('Art','Searching using:' . json_encode($config), 3);
|
||||
|
||||
$plugin_names = Plugin::get_plugins('gather_arts');
|
||||
foreach ($config as $method) {
|
||||
|
||||
if (!in_array($method, $allowed_methods)) {
|
||||
debug_event('Art', "$method not in allowed_methods, skipping", 3);
|
||||
continue;
|
||||
}
|
||||
|
||||
$method_name = "gather_" . $method;
|
||||
|
||||
if (in_array($method_name, $methods)) {
|
||||
if (in_array($method, $plugin_names)) {
|
||||
$plugin = new Plugin($method);
|
||||
$installed_version = Plugin::get_plugin_version($plugin->_plugin->name);
|
||||
if ($installed_version) {
|
||||
if ($plugin->load($GLOBALS['user'])) {
|
||||
$data = $plugin->_plugin->gather_arts($this->type, $options, $limit);
|
||||
}
|
||||
}
|
||||
} else if (in_array($method_name, $methods)) {
|
||||
debug_event('Art', "Method used: $method_name", 3);
|
||||
// Some of these take options!
|
||||
switch ($method_name) {
|
||||
case 'gather_amazon':
|
||||
$data = $this->{$method_name}($limit, $options['keyword']);
|
||||
$data = $this->{$method_name}($limit, $options);
|
||||
break;
|
||||
case 'gather_lastfm':
|
||||
$data = $this->{$method_name}($limit, $options);
|
||||
break;
|
||||
case 'gather_google':
|
||||
$data = $this->{$method_name}($limit, $options);
|
||||
break;
|
||||
default:
|
||||
$data = $this->{$method_name}($limit);
|
||||
break;
|
||||
|
@ -647,10 +712,8 @@ class Art extends database_object
|
|||
if ($limit && count($results) >= $limit) {
|
||||
return array_slice($results, 0, $limit);
|
||||
}
|
||||
|
||||
} // if the method exists
|
||||
else {
|
||||
debug_event("Art", "$method_name not defined", 1);
|
||||
} else {
|
||||
debug_event("Art", $method_name . " not defined", 1);
|
||||
}
|
||||
|
||||
} // end foreach
|
||||
|
@ -682,19 +745,17 @@ class Art extends database_object
|
|||
* This function retrieves art based on MusicBrainz' Advanced
|
||||
* Relationships
|
||||
*/
|
||||
public function gather_musicbrainz($limit = 5)
|
||||
public function gather_musicbrainz($limit = 5, $data = array())
|
||||
{
|
||||
$images = array();
|
||||
$num_found = 0;
|
||||
|
||||
if ($this->type == 'album') {
|
||||
$album = new Album($this->uid);
|
||||
} else {
|
||||
if ($this->type != 'album') {
|
||||
return $images;
|
||||
}
|
||||
|
||||
if ($album->mbid) {
|
||||
debug_event('mbz-gatherart', "Album MBID: " . $album->mbid, '5');
|
||||
if ($data['mbid']) {
|
||||
debug_event('mbz-gatherart', "Album MBID: " . $data['mbid'], '5');
|
||||
} else {
|
||||
return $images;
|
||||
}
|
||||
|
@ -704,7 +765,7 @@ class Art extends database_object
|
|||
'url-rels'
|
||||
);
|
||||
try {
|
||||
$release = $mb->lookup('release', $album->mbid, $includes);
|
||||
$release = $mb->lookup('release', $data['mbid'], $includes);
|
||||
} catch (Exception $e) {
|
||||
return $images;
|
||||
}
|
||||
|
@ -836,142 +897,6 @@ class Art extends database_object
|
|||
|
||||
} // gather_musicbrainz
|
||||
|
||||
/**
|
||||
* gather_amazon
|
||||
* This takes keywords and performs a search of the Amazon website
|
||||
* for the art. It returns an array of found objects with mime/url keys
|
||||
*/
|
||||
public function gather_amazon($limit = 5, $keywords = '')
|
||||
{
|
||||
$images = array();
|
||||
$final_results = array();
|
||||
$possible_keys = array(
|
||||
'LargeImage',
|
||||
'MediumImage',
|
||||
'SmallImage'
|
||||
);
|
||||
|
||||
if ($this->type == 'album') {
|
||||
$album = new Album($this->uid);
|
||||
} else {
|
||||
return $images;
|
||||
}
|
||||
|
||||
// Prevent the script from timing out
|
||||
set_time_limit(0);
|
||||
|
||||
if (empty($keywords)) {
|
||||
$keywords = $album->full_name;
|
||||
/* If this isn't a various album combine with artist name */
|
||||
if ($album->artist_count == '1') { $keywords .= ' ' . $album->artist_name; }
|
||||
}
|
||||
|
||||
/* Attempt to retrieve the album art order */
|
||||
$amazon_base_urls = AmpConfig::get('amazon_base_urls');
|
||||
|
||||
/* If it's not set */
|
||||
if (!count($amazon_base_urls)) {
|
||||
$amazon_base_urls = array('http://webservices.amazon.com');
|
||||
}
|
||||
|
||||
/* Foreach through the base urls that we should check */
|
||||
foreach ($amazon_base_urls as $amazon_base) {
|
||||
|
||||
// Create the Search Object
|
||||
$amazon = new AmazonSearch(AmpConfig::get('amazon_developer_public_key'), AmpConfig::get('amazon_developer_private_key'), AmpConfig::get('amazon_developer_associate_tag'), $amazon_base);
|
||||
if (AmpConfig::get('proxy_host') AND AmpConfig::get('proxy_port')) {
|
||||
$proxyhost = AmpConfig::get('proxy_host');
|
||||
$proxyport = AmpConfig::get('proxy_port');
|
||||
$proxyuser = AmpConfig::get('proxy_user');
|
||||
$proxypass = AmpConfig::get('proxy_pass');
|
||||
debug_event('amazon', 'setProxy', 5);
|
||||
$amazon->setProxy($proxyhost, $proxyport, $proxyuser, $proxypass);
|
||||
}
|
||||
|
||||
$search_results = array();
|
||||
|
||||
/* Set up the needed variables */
|
||||
$max_pages_to_search = max(AmpConfig::get('max_amazon_results_pages'),$amazon->_default_results_pages);
|
||||
// while we have pages to search
|
||||
do {
|
||||
$raw_results = $amazon->search(array('artist'=>'', 'album'=>'', 'keywords'=>$keywords));
|
||||
$total = count($raw_results) + count($search_results);
|
||||
|
||||
// If we've gotten more then we wanted
|
||||
if ($limit && $total > $limit) {
|
||||
$raw_results = array_slice($raw_results, 0, -($total - $limit), true);
|
||||
|
||||
debug_event('amazon-xml', "Found $total, limit $limit; reducing and breaking from loop", 5);
|
||||
// Merge the results and BREAK!
|
||||
$search_results = array_merge($search_results,$raw_results);
|
||||
break;
|
||||
} // if limit defined
|
||||
|
||||
$search_results = array_merge($search_results,$raw_results);
|
||||
$pages_to_search = min($max_pages_to_search, $amazon->_maxPage);
|
||||
debug_event('amazon-xml', "Searched results page " . ($amazon->_currentPage+1) . "/" . $pages_to_search,'5');
|
||||
$amazon->_currentPage++;
|
||||
|
||||
} while ($amazon->_currentPage < $pages_to_search);
|
||||
|
||||
|
||||
// Only do the second search if the first actually returns something
|
||||
if (count($search_results)) {
|
||||
$final_results = $amazon->lookup($search_results);
|
||||
}
|
||||
|
||||
/* Log this if we're doin debug */
|
||||
debug_event('amazon-xml',"Searched using $keywords with " . AmpConfig::get('amazon_developer_key') . " as key, results: " . count($final_results), 5);
|
||||
|
||||
// If we've hit our limit
|
||||
if (!empty($limit) && count($final_results) >= $limit) {
|
||||
break;
|
||||
}
|
||||
|
||||
} // end foreach
|
||||
|
||||
/* Foreach through what we've found */
|
||||
foreach ($final_results as $result) {
|
||||
|
||||
$key = '';
|
||||
/* Recurse through the images found */
|
||||
foreach ($possible_keys as $k) {
|
||||
if (strlen($result[$k])) {
|
||||
$key = $k;
|
||||
break;
|
||||
}
|
||||
} // foreach
|
||||
|
||||
// Rudimentary image type detection, only JPG and GIF allowed.
|
||||
if (substr($result[$key], -4) == '.jpg') {
|
||||
$mime = "image/jpeg";
|
||||
} elseif (substr($result[$key], -4) == '.gif') {
|
||||
$mime = "image/gif";
|
||||
} elseif (substr($result[$key], -4) == '.png') {
|
||||
$mime = "image/png";
|
||||
} else {
|
||||
/* Just go to the next result */
|
||||
continue;
|
||||
}
|
||||
|
||||
$data = array();
|
||||
$data['url'] = $result[$key];
|
||||
$data['mime'] = $mime;
|
||||
|
||||
$images[] = $data;
|
||||
|
||||
if (!empty($limit)) {
|
||||
if (count($images) >= $limit) {
|
||||
return $images;
|
||||
}
|
||||
}
|
||||
|
||||
} // if we've got something
|
||||
|
||||
return $images;
|
||||
|
||||
} // gather_amazon
|
||||
|
||||
/**
|
||||
* gather_folder
|
||||
* This returns the art from the folder of the files
|
||||
|
@ -1142,23 +1067,16 @@ class Art extends database_object
|
|||
*
|
||||
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||
*/
|
||||
public function gather_google($limit = 5)
|
||||
public function gather_google($limit = 5, $data = array())
|
||||
{
|
||||
$images = array();
|
||||
$media = new $this->type($this->uid);
|
||||
$media->format();
|
||||
|
||||
$search = $media->full_name;
|
||||
|
||||
if ($media->artist_count == '1')
|
||||
$search = $media->artist_name . ', ' . $search;
|
||||
|
||||
$search = rawurlencode($search);
|
||||
$search = rawurlencode($data['keyword']);
|
||||
|
||||
$size = '&imgsz=m'; // Medium
|
||||
//$size = '&imgsz=l'; // Large
|
||||
|
||||
$html = file_get_contents("http://images.google.com/images?source=hp&q=$search&oq=&um=1&ie=UTF-8&sa=N&tab=wi&start=0&tbo=1$size");
|
||||
$url = "http://images.google.com/images?source=hp&q=" . $search . "&oq=&um=1&ie=UTF-8&sa=N&tab=wi&start=0&tbo=1" . $size;
|
||||
$html = file_get_contents($url);
|
||||
|
||||
if(preg_match_all("|\ssrc\=\"(http.+?)\"|", $html, $matches, PREG_PATTERN_ORDER))
|
||||
foreach ($matches[1] as $match) {
|
||||
|
@ -1178,43 +1096,20 @@ class Art extends database_object
|
|||
* This returns the art from lastfm. It doesn't currently require an
|
||||
* account but may in the future.
|
||||
*/
|
||||
public function gather_lastfm($limit, $options = false)
|
||||
public function gather_lastfm($limit = 5, $data = array())
|
||||
{
|
||||
$data = array();
|
||||
// Create the parser object
|
||||
$lastfm = new LastFMSearch();
|
||||
$images = array();
|
||||
|
||||
switch ($this->type) {
|
||||
case 'album':
|
||||
if (is_array($options)) {
|
||||
$artist = $options['artist'];
|
||||
$album = $options['album_name'];
|
||||
} else {
|
||||
$media = new Album($this->uid);
|
||||
$media->format();
|
||||
$artist = $media->artist_name;
|
||||
$album = $media->full_name;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return $data;
|
||||
if ($this->type != 'album' || empty($data['artist']) || empty($data['album'])) {
|
||||
return $images;
|
||||
}
|
||||
|
||||
if (AmpConfig::get('proxy_host') AND AmpConfig::get('proxy_port')) {
|
||||
$proxyhost = AmpConfig::get('proxy_host');
|
||||
$proxyport = AmpConfig::get('proxy_port');
|
||||
$proxyuser = AmpConfig::get('proxy_user');
|
||||
$proxypass = AmpConfig::get('proxy_pass');
|
||||
debug_event('LastFM', 'proxy set', 5);
|
||||
$lastfm->setProxy($proxyhost, $proxyport, $proxyuser, $proxypass);
|
||||
}
|
||||
$xmldata = Recommendation::album_search($data['artist'], $data['album']);
|
||||
|
||||
$raw_data = $lastfm->album_search($artist, $album);
|
||||
if (!count($xmldata)) { return array(); }
|
||||
|
||||
if (!count($raw_data)) { return array(); }
|
||||
|
||||
$coverart = $raw_data['coverart'];
|
||||
if (!is_array($coverart)) { return array(); }
|
||||
$coverart = (array) $xmldata->coverart;
|
||||
if (!$coverart) { return array(); }
|
||||
|
||||
ksort($coverart);
|
||||
foreach ($coverart as $url) {
|
||||
|
@ -1225,16 +1120,67 @@ class Art extends database_object
|
|||
}
|
||||
|
||||
// HACK: we shouldn't rely on the extension to determine file type
|
||||
$results = pathinfo($url);
|
||||
$results = pathinfo($url);
|
||||
$mime = 'image/' . $results['extension'];
|
||||
$data[] = array('url' => $url, 'mime' => $mime);
|
||||
if ($limit && count($data) >= $limit) {
|
||||
return $data;
|
||||
$images[] = array('url' => $url, 'mime' => $mime);
|
||||
if ($limit && count($images) >= $limit) {
|
||||
return $images;
|
||||
}
|
||||
} // end foreach
|
||||
|
||||
return $data;
|
||||
return $images;
|
||||
|
||||
} // gather_lastfm
|
||||
|
||||
public static function gather_metadata_plugin($plugin, $type, $options)
|
||||
{
|
||||
$gtypes = array();
|
||||
switch ($type) {
|
||||
case 'tvshow':
|
||||
case 'tvshow_season':
|
||||
case 'tvshow_episode':
|
||||
$gtypes[] = 'tvshow';
|
||||
$media_info = array(
|
||||
'tvshow' => $options['tvshow'],
|
||||
'tvshow_season' => $options['tvshow_season'],
|
||||
'tvshow_episode' => $options['tvshow_episode'],
|
||||
);
|
||||
break;
|
||||
default:
|
||||
$gtypes[] = 'movie';
|
||||
$media_info = array(
|
||||
'title' => $options['keyword'],
|
||||
);
|
||||
break;
|
||||
}
|
||||
|
||||
$meta = $plugin->get_metadata($gtypes, $media_info);
|
||||
$images = array();
|
||||
switch ($type) {
|
||||
case 'tvshow':
|
||||
if ($meta['tvshow_art']) {
|
||||
$url = $meta['tvshow_art'];
|
||||
$ures = pathinfo($url);
|
||||
$images[] = array('url' => $url, 'mime' => 'image/' . $ures['extension']);
|
||||
}
|
||||
break;
|
||||
case 'tvshow_season':
|
||||
if ($meta['tvshow_season_art']) {
|
||||
$url = $meta['tvshow_season_art'];
|
||||
$ures = pathinfo($url);
|
||||
$images[] = array('url' => $url, 'mime' => 'image/' . $ures['extension']);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if ($meta['art']) {
|
||||
$url = $meta['art'];
|
||||
$ures = pathinfo($url);
|
||||
$images[] = array('url' => $url, 'mime' => 'image/' . $ures['extension']);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return $images;
|
||||
}
|
||||
|
||||
} // Art
|
||||
|
|
|
@ -466,24 +466,6 @@ abstract class Catalog extends database_object
|
|||
return $insert_id;
|
||||
}
|
||||
|
||||
public static function insert_video($gtypes, $results)
|
||||
{
|
||||
if (count($gtypes) > 0) {
|
||||
$gtype = $gtypes[0];
|
||||
switch ($gtype) {
|
||||
case 'tvshow':
|
||||
TVShow_Episode::insert($results);
|
||||
break;
|
||||
case 'movie':
|
||||
Movie::insert($results);
|
||||
break;
|
||||
default:
|
||||
// Do nothing, video entry already created and no additional data for now
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* count_tags
|
||||
*
|
||||
|
@ -605,9 +587,129 @@ abstract class Catalog extends database_object
|
|||
}
|
||||
|
||||
/**
|
||||
* get_artist
|
||||
* get_video_ids
|
||||
*
|
||||
* This returns an array of ids of videos in this catalog
|
||||
*/
|
||||
public function get_video_ids($type = '')
|
||||
{
|
||||
$results = array();
|
||||
|
||||
$sql = 'SELECT DISTINCT(`video`.`id`) FROM `video` ';
|
||||
if (!empty($type)) {
|
||||
$sql .= 'JOIN `' . $type . '` ON `' . $type . '`.`id` = `video`.`id`';
|
||||
}
|
||||
$sql .= 'WHERE `video`.`catalog` = ?';
|
||||
$db_results = Dba::read($sql, array($this->id));
|
||||
|
||||
while ($r = Dba::fetch_assoc($db_results)) {
|
||||
$results[] = $r['id'];
|
||||
}
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
public static function get_videos($catalogs = null, $type = '')
|
||||
{
|
||||
if (!$catalogs) {
|
||||
$catalogs = self::get_catalogs();
|
||||
}
|
||||
|
||||
$results = array();
|
||||
foreach ($catalogs as $catalog_id) {
|
||||
$catalog = Catalog::create_from_id($catalog_id);
|
||||
$video_ids = $catalog->get_video_ids($type);
|
||||
foreach ($video_ids as $video_id) {
|
||||
$results[] = Video::create_from_id($video_id);
|
||||
}
|
||||
}
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
public static function get_videos_count($catalog_id = null, $type = '')
|
||||
{
|
||||
$sql = "SELECT COUNT(`video`.`id`) AS `video_cnt` FROM `video` ";
|
||||
if (!empty($type)) {
|
||||
$sql .= "JOIN `" . $type . "` ON `" . $type . "`.`id` = `video`.`id` ";
|
||||
}
|
||||
if ($catalogs) {
|
||||
$sql .= "WHERE `video`.`catalog` = `" . intval($catalog_id) . "`";
|
||||
}
|
||||
$db_results = Dba::read($sql);
|
||||
$video_cnt = 0;
|
||||
if ($row = Dba::fetch_row($db_results)) {
|
||||
$video_cnt = $row[0];
|
||||
}
|
||||
|
||||
return $video_cnt;
|
||||
}
|
||||
|
||||
/**
|
||||
* get_tvshow_ids
|
||||
*
|
||||
* This returns an array of ids of tvshows in this catalog
|
||||
*/
|
||||
public function get_tvshow_ids()
|
||||
{
|
||||
$results = array();
|
||||
|
||||
$sql = 'SELECT DISTINCT(`tvshow`.`id`) FROM `tvshow` ';
|
||||
$sql .= 'JOIN `tvshow_season` ON `tvshow_season`.`tvshow` = `tvshow`.`id` ';
|
||||
$sql .= 'JOIN `tvshow_episode` ON `tvshow_episode`.`season` = `tvshow_season`.`id` ';
|
||||
$sql .= 'JOIN `video` ON `video`.`id` = `tvshow_episode`.`id` ';
|
||||
$sql .= 'WHERE `video`.`catalog` = ?';
|
||||
|
||||
$db_results = Dba::read($sql, array($this->id));
|
||||
while ($r = Dba::fetch_assoc($db_results)) {
|
||||
$results[] = $r['id'];
|
||||
}
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
public function get_tvshows($catalogs = null)
|
||||
{
|
||||
if (!$catalogs) {
|
||||
$catalogs = self::get_catalogs();
|
||||
}
|
||||
|
||||
$results = array();
|
||||
foreach ($catalogs as $catalog_id) {
|
||||
$catalog = Catalog::create_from_id($catalog_id);
|
||||
$tvshow_ids = $catalog->get_tvshow_ids($type);
|
||||
foreach ($tvshow_ids as $tvshow_id) {
|
||||
$results[] = new TVShow($tvshow_id);
|
||||
}
|
||||
}
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
/**
|
||||
* get_artist_ids
|
||||
*
|
||||
* This returns an array of ids of artist that have songs in this
|
||||
* catalog
|
||||
*/
|
||||
public function get_artist_ids()
|
||||
{
|
||||
$results = array();
|
||||
|
||||
$sql = 'SELECT DISTINCT(`song`.`artist`) FROM `song` WHERE `song`.`catalog` = ?';
|
||||
$db_results = Dba::read($sql, array($this->id));
|
||||
|
||||
while ($r = Dba::fetch_assoc($db_results)) {
|
||||
$results[] = $r['artist'];
|
||||
}
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
/**
|
||||
* get_artists
|
||||
*
|
||||
* This returns an array of ids of artists that have songs in the catalogs parameter
|
||||
* This returns an array of artists that have songs in the catalogs parameter
|
||||
*/
|
||||
public static function get_artists($catalogs = null)
|
||||
{
|
||||
|
@ -707,7 +809,7 @@ abstract class Catalog extends database_object
|
|||
* This runs through all of the needs art albums and trys
|
||||
* to find the art for them from the mp3s
|
||||
*/
|
||||
public function gather_art()
|
||||
public function gather_art($songs = null, $videos = null)
|
||||
{
|
||||
// Make sure they've actually got methods
|
||||
$art_order = AmpConfig::get('art_order');
|
||||
|
@ -720,55 +822,68 @@ abstract class Catalog extends database_object
|
|||
set_time_limit(0);
|
||||
|
||||
$search_count = 0;
|
||||
$albums = $this->get_album_ids();
|
||||
|
||||
// Run through them and get the art!
|
||||
foreach ($albums as $album_id) {
|
||||
$art = new Art($album_id, 'album');
|
||||
$album = new Album($album_id);
|
||||
// We're going to need the name here
|
||||
$album->format();
|
||||
|
||||
debug_event('gather_art', 'Gathering art for ' . $album->name, 5);
|
||||
|
||||
$options = array(
|
||||
'album_name' => $album->full_name,
|
||||
'artist' => $album->artist_name,
|
||||
'keyword' => $album->artist_name . ' ' . $album->full_name
|
||||
);
|
||||
|
||||
$results = $art->gather($options, 1);
|
||||
|
||||
if (count($results)) {
|
||||
// Pull the string representation from the source
|
||||
$image = Art::get_from_source($results[0], 'album');
|
||||
if (strlen($image) > '5') {
|
||||
$art->insert($image, $results[0]['mime']);
|
||||
// If they've enabled resizing of images generate a thumbnail
|
||||
if (AmpConfig::get('resize_images')) {
|
||||
$thumb = $art->generate_thumb($image, array(
|
||||
'width' => 275,
|
||||
'height' => 275),
|
||||
$results[0]['mime']);
|
||||
if (is_array($thumb)) {
|
||||
$art->save_thumb($thumb['thumb'], $thumb['thumb_mime'], '275x275');
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
debug_event('gather_art', 'Image less than 5 chars, not inserting', 3);
|
||||
$searches = array();
|
||||
if ($songs == null) {
|
||||
$searches['album'] = $this->get_album_ids();
|
||||
$searches['artist'] = $this->get_artist_ids();
|
||||
} else {
|
||||
$searches['album'] = array();
|
||||
$searches['artist'] = array();
|
||||
foreach ($songs as $song_id) {
|
||||
$song = new Song($song_id);
|
||||
if (!in_array($song->album, $albums)) {
|
||||
$searches['album'][] = $song->album;
|
||||
}
|
||||
if (!in_array($song->artist, $albums)) {
|
||||
$searches['artist'][] = $song->artist;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($videos == null) {
|
||||
$searches['video'] = $this->get_video_ids();
|
||||
} else {
|
||||
$searches['video'] = $videos;
|
||||
}
|
||||
|
||||
// Stupid little cutesie thing
|
||||
$search_count++;
|
||||
if (UI::check_ticker()) {
|
||||
UI::update_text('count_art_' . $this->id, $search_count);
|
||||
UI::update_text('read_art_' . $this->id, scrub_out($album->name));
|
||||
// Run through items and get the art!
|
||||
foreach ($searches as $key => $values) {
|
||||
foreach ($values as $id) {
|
||||
$art = new Art($id, $key);
|
||||
|
||||
debug_event('gather_art', 'Gathering art for ' . $key . '/' . $id . '...', 5);
|
||||
$results = $art->gather(array(), 1);
|
||||
|
||||
if (count($results)) {
|
||||
// Pull the string representation from the source
|
||||
$image = Art::get_from_source($results[0], $key);
|
||||
if (strlen($image) > '5') {
|
||||
$art->insert($image, $results[0]['mime']);
|
||||
// If they've enabled resizing of images generate a thumbnail
|
||||
if (AmpConfig::get('resize_images')) {
|
||||
$thumb = $art->generate_thumb($image, array(
|
||||
'width' => 275,
|
||||
'height' => 275),
|
||||
$results[0]['mime']);
|
||||
if (is_array($thumb)) {
|
||||
$art->save_thumb($thumb['thumb'], $thumb['thumb_mime'], '275x275');
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
debug_event('gather_art', 'Image less than 5 chars, not inserting', 3);
|
||||
}
|
||||
}
|
||||
|
||||
// Stupid little cutesie thing
|
||||
$search_count++;
|
||||
if (UI::check_ticker()) {
|
||||
UI::update_text('count_art_' . $this->id, $search_count);
|
||||
UI::update_text('read_art_' . $this->id, scrub_out($album->name));
|
||||
}
|
||||
|
||||
unset($found);
|
||||
}
|
||||
|
||||
unset($found);
|
||||
} // foreach albums
|
||||
}
|
||||
|
||||
// One last time for good measure
|
||||
UI::update_text('count_art_' . $this->id, $search_count);
|
||||
|
|
|
@ -63,7 +63,7 @@ class Clip extends Video
|
|||
* create
|
||||
* This takes a key'd array of data as input and inserts a new clip entry, it returns the record id
|
||||
*/
|
||||
public static function insert($data)
|
||||
public static function insert($data, $options = array())
|
||||
{
|
||||
$sql = "INSERT INTO `clip` (`id`,`artist`,`song`) " .
|
||||
"VALUES (?, ?, ?)";
|
||||
|
|
|
@ -61,7 +61,7 @@ class Movie extends Video
|
|||
* create
|
||||
* This takes a key'd array of data as input and inserts a new movie entry, it returns the record id
|
||||
*/
|
||||
public static function insert($data)
|
||||
public static function insert($data, $options = array())
|
||||
{
|
||||
$sql = "INSERT INTO `movie` (`id`,`original_name`,`description`, `year`) " .
|
||||
"VALUES (?, ?, ?, ?)";
|
||||
|
@ -93,7 +93,9 @@ class Movie extends Video
|
|||
{
|
||||
parent::format();
|
||||
|
||||
$this->f_link = '<a href="' . $this->link . '">' . ($this->original_name ?: $this->f_title) . '</a>';
|
||||
$this->f_title = ($this->original_name ?: $this->f_title);
|
||||
$this->f_full_title = $this->f_title;
|
||||
$this->f_link = '<a href="' . $this->link . '">' . $this->f_title . '</a>';
|
||||
|
||||
return true;
|
||||
|
||||
|
|
|
@ -62,7 +62,7 @@ class Personal_Video extends Video
|
|||
* create
|
||||
* This takes a key'd array of data as input and inserts a new personal video entry, it returns the record id
|
||||
*/
|
||||
public static function insert($data)
|
||||
public static function insert($data, $options = array())
|
||||
{
|
||||
$sql = "INSERT INTO `personal_video` (`id`,`location`,`description`) " .
|
||||
"VALUES (?, ?, ?)";
|
||||
|
|
|
@ -363,7 +363,7 @@ class Preference extends database_object
|
|||
public static function fix_preferences($results)
|
||||
{
|
||||
$arrays = array('auth_methods', 'getid3_tag_order',
|
||||
'metadata_order', 'metadata_order_video', 'art_order', 'amazon_base_urls');
|
||||
'metadata_order', 'metadata_order_video', 'art_order');
|
||||
|
||||
foreach ($arrays as $item) {
|
||||
$results[$item] = trim($results[$item])
|
||||
|
|
|
@ -40,6 +40,12 @@ class Recommendation
|
|||
$api_key = AmpConfig::get('lastfm_api_key');
|
||||
$api_base = "http://ws.audioscrobbler.com/2.0/?method=";
|
||||
$url = $api_base . $method . '&api_key=' . $api_key . '&' . $query;
|
||||
|
||||
return self::query_lastfm($url);
|
||||
}
|
||||
|
||||
public static function query_lastfm($url)
|
||||
{
|
||||
debug_event('Recommendation', 'search url : ' . $url, 5);
|
||||
|
||||
$options = array();
|
||||
|
@ -56,7 +62,14 @@ class Recommendation
|
|||
$content = $request->body;
|
||||
|
||||
return simplexml_load_string($content);
|
||||
} // get_lastfm_results
|
||||
}
|
||||
|
||||
public static function album_search($artist, $album)
|
||||
{
|
||||
$url = 'http://ws.audioscrobbler.com/1.0/album/' . urlencode($artist) . '/' . urlencode($album) . '/info.xml';
|
||||
|
||||
return self::query_lastfm($url);
|
||||
}
|
||||
|
||||
/**
|
||||
* gc
|
||||
|
|
|
@ -166,11 +166,11 @@ class Shoutbox
|
|||
{
|
||||
switch ($this->object_type) {
|
||||
case 'album':
|
||||
$image_string = "<img class=\"shoutboximage\" height=\"75\" width=\"75\" src=\"" . AmpConfig::get('web_path') . "/image.php?id=" . $this->object_id . "&thumb=1\" />";
|
||||
$image_string = "<img class=\"shoutboximage\" height=\"75\" width=\"75\" src=\"" . AmpConfig::get('web_path') . "/image.php?object_id=" . $this->object_id . "&object_type=" . $this->object_type . "&thumb=1\" />";
|
||||
break;
|
||||
case 'song':
|
||||
$song = new Song($this->object_id);
|
||||
$image_string = "<img class=\"shoutboximage\" height=\"75\" width=\"75\" src=\"" . AmpConfig::get('web_path') . "/image.php?id=" . $song->album . "&thumb=1\" />";
|
||||
$image_string = "<img class=\"shoutboximage\" height=\"75\" width=\"75\" src=\"" . AmpConfig::get('web_path') . "/image.php?object_id=" . $song->album . "&object_type=album&thumb=1\" />";
|
||||
break;
|
||||
case 'artist':
|
||||
default:
|
||||
|
|
|
@ -375,10 +375,11 @@ class Song extends database_object implements media
|
|||
return 'audio/aacp';
|
||||
case 'mpc':
|
||||
return 'audio/x-musepack';
|
||||
case 'mkv':
|
||||
return 'audio/x-matroska';
|
||||
default:
|
||||
return 'audio/mpeg';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -85,11 +85,19 @@ class Subsonic_Api
|
|||
public static function follow_stream($url)
|
||||
{
|
||||
set_time_limit(0);
|
||||
ob_end_clean();
|
||||
|
||||
if (function_exists('curl_version')) {
|
||||
$headers = apache_request_headers();
|
||||
$reqheaders = array();
|
||||
$reqheaders[] = "User-Agent: " . $headers['User-Agent'];
|
||||
if (isset($headers['Range'])) {
|
||||
$reqheaders[] = "Range: " . $headers['Range'];
|
||||
}
|
||||
// Curl support, we stream transparently to avoid redirect. Redirect can fail on few clients
|
||||
$ch = curl_init($url);
|
||||
curl_setopt_array($ch, array(
|
||||
CURLOPT_HTTPHEADER => $reqheaders,
|
||||
CURLOPT_HEADER => false,
|
||||
CURLOPT_RETURNTRANSFER => false,
|
||||
CURLOPT_FOLLOWLOCATION => true,
|
||||
|
@ -423,14 +431,14 @@ class Subsonic_Api
|
|||
* getVideos
|
||||
* Get all videos.
|
||||
* Takes no parameter.
|
||||
* Not supported yet.
|
||||
*/
|
||||
public static function getvideos($input)
|
||||
{
|
||||
self::check_version($input, "1.7.0");
|
||||
|
||||
$r = Subsonic_XML_Data::createSuccessResponse();
|
||||
Subsonic_XML_Data::addVideos($r);
|
||||
$videos = Catalog::get_videos();
|
||||
Subsonic_XML_Data::addVideos($r, $videos);
|
||||
self::apiOutput($input, $r);
|
||||
}
|
||||
|
||||
|
@ -844,8 +852,17 @@ class Subsonic_Api
|
|||
if ($estimateContentLength == 'true') {
|
||||
$params .= '&content_length=required';
|
||||
}
|
||||
$url = Song::play_url(Subsonic_XML_Data::getAmpacheId($fileid), $params);
|
||||
self::follow_stream($url);
|
||||
|
||||
$url = '';
|
||||
if (Subsonic_XML_Data::isVideo($fileid)) {
|
||||
$url = Video::play_url(Subsonic_XML_Data::getAmpacheId($fileid), $params);
|
||||
} else if (Subsonic_XML_Data::isSong($fileid)) {
|
||||
$url = Song::play_url(Subsonic_XML_Data::getAmpacheId($fileid), $params);
|
||||
}
|
||||
|
||||
if (!empty($url)) {
|
||||
self::follow_stream($url);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -46,6 +46,7 @@ class Subsonic_XML_Data
|
|||
const AMPACHEID_ALBUM = 200000000;
|
||||
const AMPACHEID_SONG = 300000000;
|
||||
const AMPACHEID_SMARTPL = 400000000;
|
||||
const AMPACHEID_VIDEO = 500000000;
|
||||
|
||||
/**
|
||||
* constructor
|
||||
|
@ -76,6 +77,11 @@ class Subsonic_XML_Data
|
|||
return $id + Subsonic_XML_Data::AMPACHEID_SMARTPL;
|
||||
}
|
||||
|
||||
public static function getVideoId($id)
|
||||
{
|
||||
return $id + Subsonic_XML_Data::AMPACHEID_VIDEO;
|
||||
}
|
||||
|
||||
public static function getAmpacheId($id)
|
||||
{
|
||||
return ($id % Subsonic_XML_Data::AMPACHEID_ARTIST);
|
||||
|
@ -110,6 +116,11 @@ class Subsonic_XML_Data
|
|||
return ($id >= Subsonic_XML_Data::AMPACHEID_SMARTPL);
|
||||
}
|
||||
|
||||
public static function isVideo($id)
|
||||
{
|
||||
return ($id >= Subsonic_XML_Data::AMPACHEID_VIDEO);
|
||||
}
|
||||
|
||||
public static function createFailedResponse($version = "")
|
||||
{
|
||||
$response = self::createResponse($version);
|
||||
|
@ -404,10 +415,48 @@ class Subsonic_XML_Data
|
|||
}
|
||||
}
|
||||
|
||||
public static function addVideos($xml)
|
||||
public static function addVideos($xml, $videos)
|
||||
{
|
||||
// Not supported yet
|
||||
$xml->addChild('videos');
|
||||
$xvideos = $xml->addChild('videos');
|
||||
foreach ($videos as $video) {
|
||||
$video->format();
|
||||
self::addVideo($xvideos, $video);
|
||||
}
|
||||
}
|
||||
|
||||
public static function addVideo($xml, $video)
|
||||
{
|
||||
$xvideo = $xml->addChild('video');
|
||||
$xvideo->addAttribute('id', self::getVideoId($video->id));
|
||||
$xvideo->addAttribute('title', $video->f_full_title);
|
||||
$xvideo->addAttribute('isDir', 'false');
|
||||
$xvideo->addAttribute('coverArt', self::getVideoId($video->id));
|
||||
$xvideo->addAttribute('isVideo', 'true');
|
||||
$xvideo->addAttribute('type', 'video');
|
||||
$xvideo->addAttribute('duration', $video->time);
|
||||
if ($video->year > 0) {
|
||||
$xvideo->addAttribute('year', $video->year);
|
||||
}
|
||||
$tags = Tag::get_object_tags('video', $video->id);
|
||||
if (count($tags) > 0) $xvideo->addAttribute('genre', $tags[0]['name']);
|
||||
$xvideo->addAttribute('size', $video->size);
|
||||
$xvideo->addAttribute('suffix', $video->type);
|
||||
$xvideo->addAttribute('contentType', $video->mime);
|
||||
// Create a clean fake path instead of song real file path to have better offline mode storage on Subsonic clients
|
||||
$path = basename($video->file);
|
||||
$xvideo->addAttribute('path', $path);
|
||||
|
||||
// Set transcoding information if required
|
||||
$transcode_cfg = AmpConfig::get('transcode');
|
||||
$transcode_mode = AmpConfig::get('transcode_' . $video->type);
|
||||
if ($transcode_cfg == 'always' || ($transcode_cfg != 'never' && $transcode_mode == 'required')) {
|
||||
$transcode_settings = $video->get_transcode_settings(null);
|
||||
if ($transcode_settings) {
|
||||
$transcode_type = $transcode_settings['format'];
|
||||
$xvideo->addAttribute('transcodedSuffix', $transcode_type);
|
||||
$xvideo->addAttribute('transcodedContentType', Video::type_to_mime($transcode_type));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function addPlaylists($xml, $playlists, $smartplaylists = array())
|
||||
|
|
|
@ -288,6 +288,14 @@ class Tag extends database_object
|
|||
"WHERE `tag_map`.`object_type`='video' AND `video`.`id` IS NULL";
|
||||
Dba::write($sql);
|
||||
|
||||
$sql = "DELETE FROM `tag_map` USING `tag_map` LEFT JOIN `tvshow` ON `tvshow`.`id`=`tag_map`.`object_id` " .
|
||||
"WHERE `tag_map`.`object_type`='tvshow' AND `tvshow`.`id` IS NULL";
|
||||
Dba::write($sql);
|
||||
|
||||
$sql = "DELETE FROM `tag_map` USING `tag_map` LEFT JOIN `tvshow_season` ON `tvshow_season`.`id`=`tag_map`.`object_id` " .
|
||||
"WHERE `tag_map`.`object_type`='tvshow_season' AND `tvshow_season`.`id` IS NULL";
|
||||
Dba::write($sql);
|
||||
|
||||
// Now nuke the tags themselves
|
||||
$sql = "DELETE FROM `tag` USING `tag` LEFT JOIN `tag_map` ON `tag`.`id`=`tag_map`.`tag_id` " .
|
||||
"WHERE `tag_map`.`id` IS NULL";
|
||||
|
@ -599,7 +607,7 @@ class Tag extends database_object
|
|||
*/
|
||||
public static function validate_type($type)
|
||||
{
|
||||
$valid_array = array('song','artist','album','video','playlist','live_stream','channel','broadcast');
|
||||
$valid_array = array('song','artist','album','video','tvshow','tvshow_season','playlist','live_stream','channel','broadcast');
|
||||
|
||||
if (in_array($type,$valid_array)) { return $type; }
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@ class TVShow_Episode extends Video
|
|||
public $description;
|
||||
|
||||
public $f_link;
|
||||
public $f_season;
|
||||
public $f_season_link;
|
||||
public $f_tvshow;
|
||||
public $f_tvshow_link;
|
||||
|
@ -65,14 +66,33 @@ class TVShow_Episode extends Video
|
|||
* insert
|
||||
* Insert a new tv show episode and related entities.
|
||||
*/
|
||||
public static function insert($data)
|
||||
public static function insert($data, $options = array())
|
||||
{
|
||||
if (empty($data['tvshow'])) {
|
||||
$data['tvshow'] = T_('Unknown');
|
||||
}
|
||||
$tags = $data['genre'];
|
||||
|
||||
$tvshow = TVShow::check($data['tvshow'], $data['tvshow_year']);
|
||||
if ($options['gather_art'] && $tvshow && $data['tvshow_art'] && !Art::has_db($tvshow, 'tvshow')) {
|
||||
$art = new Art($tvshow, 'tvshow');
|
||||
$art->insert_url($data['tvshow_art']);
|
||||
}
|
||||
$tvshow_season = TVShow_Season::check($tvshow, $data['tvshow_season']);
|
||||
if ($options['gather_art'] && $tvshow_season && $data['tvshow_season_art'] && !Art::has_db($tvshow_season, 'tvshow_season')) {
|
||||
$art = new Art($tvshow_season, 'tvshow_season');
|
||||
$art->insert_url($data['tvshow_season_art']);
|
||||
}
|
||||
|
||||
if (is_array($tags)) {
|
||||
foreach ($tags as $tag) {
|
||||
$tag = trim($tag);
|
||||
if (!empty($tag)) {
|
||||
Tag::add('tvshow_season', $tvshow_season, $tag, false);
|
||||
Tag::add('tvshow', $tvshow, $tag, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$sdata = $data;
|
||||
// Replace relation name with db ids
|
||||
|
@ -121,8 +141,9 @@ class TVShow_Episode extends Video
|
|||
|
||||
$this->f_title = ($this->original_name ?: $this->f_title);
|
||||
$this->f_link = '<a href="' . $this->link . '">' . $this->f_title . '</a>';
|
||||
$this->f_season = $season->f_name;
|
||||
$this->f_season_link = $season->f_link;
|
||||
$this->f_tvshow = $tvshow->f_tvshow;
|
||||
$this->f_tvshow = $season->f_tvshow;
|
||||
$this->f_tvshow_link = $season->f_tvshow_link;
|
||||
|
||||
$this->f_file = $this->f_tvshow;
|
||||
|
@ -130,6 +151,7 @@ class TVShow_Episode extends Video
|
|||
$this->f_file .= ' - S'. sprintf('%02d', $season->season_number) . 'E'. sprintf('%02d', $this->episode_number);
|
||||
}
|
||||
$this->f_file .= ' - ' . $this->f_title;
|
||||
$this->f_full_title = $this->f_file;
|
||||
|
||||
return true;
|
||||
|
||||
|
|
|
@ -2715,19 +2715,6 @@ class Update
|
|||
$sql = "ALTER TABLE `video` ADD `release_date` int(11) unsigned NULL AFTER `enabled`";
|
||||
Dba::write($sql);
|
||||
|
||||
$sql = "CREATE TABLE `people` (" .
|
||||
"`id` int(11) unsigned NOT NULL AUTO_INCREMENT," .
|
||||
"`name` varchar(256) NOT NULL," .
|
||||
"PRIMARY KEY (`id`)) ENGINE = MYISAM";
|
||||
|
||||
$sql = "CREATE TABLE `people_rel` (" .
|
||||
"`id` int(11) unsigned NOT NULL AUTO_INCREMENT," .
|
||||
"`object_id` int(11) unsigned NOT NULL," .
|
||||
"`object_type` varchar(32) NOT NULL," .
|
||||
"`people_id` int(11) unsigned NOT NULL," .
|
||||
"`rel_type` varchar(32) NOT NULL," .
|
||||
"PRIMARY KEY (`id`)) ENGINE = MYISAM";
|
||||
|
||||
$sql = "CREATE TABLE `tvshow` (" .
|
||||
"`id` int(11) unsigned NOT NULL AUTO_INCREMENT," .
|
||||
"`name` varchar(80) NOT NULL," .
|
||||
|
|
|
@ -572,6 +572,237 @@ class Upnp_Api
|
|||
return $mediaItems;
|
||||
}
|
||||
|
||||
public static function _videoMetadata($prmPath, $prmQuery = '')
|
||||
{
|
||||
$root = 'amp://video';
|
||||
$pathreq = explode('/', $prmPath);
|
||||
if ($pathreq[0] == '' && count($pathreq) > 0) {
|
||||
array_shift($pathreq);
|
||||
}
|
||||
|
||||
$meta = null;
|
||||
switch ($pathreq[0]) {
|
||||
case 'tvshows':
|
||||
switch (count($pathreq)) {
|
||||
case 1:
|
||||
$counts = count(Catalog::get_tvshows());
|
||||
$meta = array(
|
||||
'id' => $root . '/tvshows',
|
||||
'parentID' => $root,
|
||||
'restricted' => '1',
|
||||
'childCount' => $counts,
|
||||
'dc:title' => T_('TV Shows'),
|
||||
'upnp:class' => 'object.container',
|
||||
);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
$tvshow = new TVShow($pathreq[1]);
|
||||
if ($tvshow->id) {
|
||||
$tvshow->format();
|
||||
$meta = self::_itemTVShow($tvshow, $root . '/tvshows');
|
||||
}
|
||||
break;
|
||||
|
||||
case 3:
|
||||
$season = new TVShow_Season($pathreq[2]);
|
||||
if ($season->id) {
|
||||
$season->format();
|
||||
$meta = self::_itemTVShowSeason($season, $root . '/tvshows/' . $pathreq[1]);
|
||||
}
|
||||
break;
|
||||
|
||||
case 4:
|
||||
$video = new TVShow_Episode($pathreq[3]);
|
||||
if ($video->id) {
|
||||
$video->format();
|
||||
$meta = self::_itemVideo($video, $root . '/tvshows/' . $pathreq[1] . '/' . $pathreq[2] );
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'clips':
|
||||
switch (count($pathreq)) {
|
||||
case 1:
|
||||
$counts = Catalog::get_videos_count(null, 'clip');
|
||||
$meta = array(
|
||||
'id' => $root . '/clips',
|
||||
'parentID' => $root,
|
||||
'restricted' => '1',
|
||||
'childCount' => $counts,
|
||||
'dc:title' => T_('Clips'),
|
||||
'upnp:class' => 'object.container',
|
||||
);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
$video = new Clip($pathreq[1]);
|
||||
if ($video->id) {
|
||||
$video->format();
|
||||
$meta = self::_itemVideo($video, $root . '/clips');
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'movies':
|
||||
switch (count($pathreq)) {
|
||||
case 1:
|
||||
$counts = Catalog::get_videos_count(null, 'movie');
|
||||
$meta = array(
|
||||
'id' => $root . '/movies',
|
||||
'parentID' => $root,
|
||||
'restricted' => '1',
|
||||
'childCount' => $counts,
|
||||
'dc:title' => T_('Movies'),
|
||||
'upnp:class' => 'object.container',
|
||||
);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
$video = new Movie($pathreq[1]);
|
||||
if ($video->id) {
|
||||
$video->format();
|
||||
$meta = self::_itemVideo($video, $root . '/movies');
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'personal_videos':
|
||||
switch (count($pathreq)) {
|
||||
case 1:
|
||||
$counts = Catalog::get_videos_count(null, 'personal_video');
|
||||
$meta = array(
|
||||
'id' => $root . '/personal_videos',
|
||||
'parentID' => $root,
|
||||
'restricted' => '1',
|
||||
'childCount' => $counts,
|
||||
'dc:title' => T_('Personal Videos'),
|
||||
'upnp:class' => 'object.container',
|
||||
);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
$video = new Personal_Video($pathreq[1]);
|
||||
if ($video->id) {
|
||||
$video->format();
|
||||
$meta = self::_itemVideo($video, $root . '/personal_videos');
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
$meta = array(
|
||||
'id' => $root,
|
||||
'parentID' => '0',
|
||||
'restricted' => '1',
|
||||
'childCount' => '4',
|
||||
'dc:title' => T_('Video'),
|
||||
'upnp:class' => 'object.container',
|
||||
);
|
||||
break;
|
||||
}
|
||||
|
||||
return $meta;
|
||||
}
|
||||
|
||||
public static function _videoChilds($prmPath, $prmQuery)
|
||||
{
|
||||
$mediaItems = array();
|
||||
$queryData = array();
|
||||
parse_str($prmQuery, $queryData);
|
||||
|
||||
$parent = 'amp://video' . $prmPath;
|
||||
$pathreq = explode('/', $prmPath);
|
||||
if ($pathreq[0] == '' && count($pathreq) > 0) {
|
||||
array_shift($pathreq);
|
||||
}
|
||||
|
||||
switch ($pathreq[0]) {
|
||||
case 'tvshows':
|
||||
switch (count($pathreq)) {
|
||||
case 1: // Get tvshow list
|
||||
$tvshows = Catalog::get_tvshows();
|
||||
foreach ($tvshows as $tvshow) {
|
||||
$tvshow->format();
|
||||
$mediaItems[] = self::_itemTVShow($tvshow, $parent);
|
||||
}
|
||||
break;
|
||||
case 2: // Get season list
|
||||
$tvshow = new TVShow($pathreq[1]);
|
||||
if ($tvshow->id) {
|
||||
$season_ids = $tvshow->get_seasons();
|
||||
foreach ($season_ids as $season_id) {
|
||||
$season = new TVShow_Season($season_id);
|
||||
$season->format();
|
||||
$mediaItems[] = self::_itemTVShowSeason($season, $parent);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 3: // Get episode list
|
||||
$season = new TVShow_Season($pathreq[2]);
|
||||
if ($season->id) {
|
||||
$episode_ids = $season->get_episodes();
|
||||
foreach ($episode_ids as $episode_id) {
|
||||
$video = new Video($episode_id);
|
||||
$video->format();
|
||||
$mediaItems[] = self::_itemVideo($video, $parent);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'clips':
|
||||
switch (count($pathreq)) {
|
||||
case 1: // Get clips list
|
||||
$videos = Catalog::get_videos(null, 'clip');
|
||||
foreach ($videos as $video) {
|
||||
$video->format();
|
||||
$mediaItems[] = self::_itemVideo($video, $parent);
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'movies':
|
||||
switch (count($pathreq)) {
|
||||
case 1: // Get clips list
|
||||
$videos = Catalog::get_videos(null, 'movie');
|
||||
foreach ($videos as $video) {
|
||||
$video->format();
|
||||
$mediaItems[] = self::_itemVideo($video, $parent);
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'personal_videos':
|
||||
switch (count($pathreq)) {
|
||||
case 1: // Get clips list
|
||||
$videos = Catalog::get_videos(null, 'personal_video');
|
||||
foreach ($videos as $video) {
|
||||
$video->format();
|
||||
$mediaItems[] = self::_itemVideo($video, $parent);
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
$mediaItems[] = self::_videoMetadata('clips');
|
||||
$mediaItems[] = self::_videoMetadata('tvshows');
|
||||
$mediaItems[] = self::_videoMetadata('movies');
|
||||
$mediaItems[] = self::_videoMetadata('personal_videos');
|
||||
break;
|
||||
}
|
||||
|
||||
return $mediaItems;
|
||||
}
|
||||
|
||||
public static function _callSearch($criteria)
|
||||
{
|
||||
// Not supported yet
|
||||
|
@ -662,6 +893,54 @@ class Upnp_Api
|
|||
);
|
||||
}
|
||||
|
||||
private static function _itemTVShow($tvshow, $parent)
|
||||
{
|
||||
return array(
|
||||
'id' => 'amp://video/tvshows/' . $tvshow->id,
|
||||
'parentID' => $parent,
|
||||
'restricted' => '1',
|
||||
'childCount' => count($tvshow->get_seasons()),
|
||||
'dc:title' => $tvshow->f_name,
|
||||
'upnp:class' => 'object.container',
|
||||
);
|
||||
}
|
||||
|
||||
private static function _itemTVShowSeason($season, $parent)
|
||||
{
|
||||
return array(
|
||||
'id' => 'amp://video/tvshows/' . $season->tvshow . '/' . $season->id,
|
||||
'parentID' => $parent,
|
||||
'restricted' => '1',
|
||||
'childCount' => count($season->get_episodes()),
|
||||
'dc:title' => $season->f_name,
|
||||
'upnp:class' => 'object.container',
|
||||
);
|
||||
}
|
||||
|
||||
private static function _itemVideo($video, $parent)
|
||||
{
|
||||
$api_session = (AmpConfig::get('require_session')) ? Stream::$session : false;
|
||||
$art_url = Art::url($video->id, 'video', $api_session);
|
||||
|
||||
$fileTypesByExt = self::_getFileTypes();
|
||||
$arrFileType = $fileTypesByExt[$video->type];
|
||||
|
||||
return array(
|
||||
'id' => $parent . '/' . $video->id,
|
||||
'parentID' => $parent,
|
||||
'restricted' => '1',
|
||||
'dc:title' => $video->f_title,
|
||||
'upnp:class' => (isset($arrFileType['class'])) ? $arrFileType['class'] : 'object.item.unknownItem',
|
||||
'upnp:albumArtURI' => $art_url,
|
||||
'upnp:genre' => Tag::get_display($video->tags, false, 'video'),
|
||||
|
||||
'res' => Video::play_url($video->id),
|
||||
'protocolInfo' => $arrFileType['mime'],
|
||||
'size' => $video->size,
|
||||
'duration' => $video->f_time_h . '.0',
|
||||
);
|
||||
}
|
||||
|
||||
private static function _getFileTypes()
|
||||
{
|
||||
return array(
|
||||
|
|
|
@ -1155,7 +1155,7 @@ class User extends database_object
|
|||
$avatar['title'] = T_('User avatar');
|
||||
$upavatar = new Art($this->id, 'user');
|
||||
if ($upavatar->get_db()) {
|
||||
$avatar['url'] = AmpConfig::get('web_path') . '/image.php?object_type=user&id=' . $this->id;
|
||||
$avatar['url'] = AmpConfig::get('web_path') . '/image.php?object_type=user&object_id=' . $this->id;
|
||||
$avatar['url_mini'] = $avatar['url'];
|
||||
$avatar['url_medium'] = $avatar['url'];
|
||||
$avatar['url'] .= '&thumb=4';
|
||||
|
|
|
@ -298,19 +298,9 @@ class vainfo
|
|||
$info['album'] = $info['album'] ?: trim($tags['album']);
|
||||
|
||||
$info['band'] = $info['band'] ?: trim($tags['band']);
|
||||
$info['composer'] = $info['composer'] ?: trim($tags['composer']);
|
||||
|
||||
// multiple genre support
|
||||
if ((!$info['genre']) && $tags['genre']) {
|
||||
if (!is_array($tags['genre'])) {
|
||||
// not all tag formats will return an array, but we need one
|
||||
$info['genre'][] = trim($tags['genre']);
|
||||
} else {
|
||||
// if we trim the array we lose everything after 1st entry
|
||||
foreach ($tags['genre'] as $genre) {
|
||||
$info['genre'][] = trim($genre);
|
||||
}
|
||||
}
|
||||
}
|
||||
$info['genre'] = self::clean_array_tag('genre', $info, $tags);
|
||||
|
||||
$info['mb_trackid'] = $info['mb_trackid'] ?: trim($tags['mb_trackid']);
|
||||
$info['mb_albumid'] = $info['mb_albumid'] ?: trim($tags['mb_albumid']);
|
||||
|
@ -330,12 +320,17 @@ class vainfo
|
|||
$info['resolution_y'] = $info['resolution_y'] ?: intval($tags['resolution_y']);
|
||||
$info['audio_codec'] = $info['audio_codec'] ?: trim($tags['audio_codec']);
|
||||
$info['video_codec'] = $info['video_codec'] ?: trim($tags['video_codec']);
|
||||
$info['description'] = $info['description'] ?: trim($tags['description']);
|
||||
|
||||
$info['tvshow'] = $info['tvshow'] ?: trim($tags['tvshow']);
|
||||
$info['tvshow_year'] = $info['tvshow_year'] ?: trim($tags['tvshow_year']);
|
||||
$info['tvshow_season'] = $info['tvshow_season'] ?: trim($tags['tvshow_season']);
|
||||
$info['tvshow_episode'] = $info['tvshow_episode'] ?: trim($tags['tvshow_episode']);
|
||||
$info['release_date'] = $info['release_date'] ?: trim($tags['release_date']);
|
||||
|
||||
$info['tvshow_art'] = $info['tvshow_art'] ?: trim($tags['tvshow_art']);
|
||||
$info['tvshow_season_art'] = $info['tvshow_season_art'] ?: trim($tags['tvshow_season_art']);
|
||||
$info['art'] = $info['art'] ?: trim($tags['art']);
|
||||
}
|
||||
|
||||
// Some things set the disk number even though there aren't multiple
|
||||
|
@ -347,6 +342,25 @@ class vainfo
|
|||
return $info;
|
||||
}
|
||||
|
||||
private static function clean_array_tag($field, $info, $tags)
|
||||
{
|
||||
$arr = array();
|
||||
if ((!$info[$field] || count($info[$field]) == 0) && $tags[$field]) {
|
||||
if (!is_array($tags[$field])) {
|
||||
// not all tag formats will return an array, but we need one
|
||||
$arr[] = trim($tags[$field]);
|
||||
} else {
|
||||
foreach ($tags[$field] as $genre) {
|
||||
$arr[] = trim($genre);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$arr = $info[$field];
|
||||
}
|
||||
|
||||
return $arr;
|
||||
}
|
||||
|
||||
/**
|
||||
* _get_type
|
||||
*
|
||||
|
|
|
@ -36,8 +36,12 @@ class Video extends database_object implements media
|
|||
public $release_date;
|
||||
public $catalog;
|
||||
|
||||
public $type;
|
||||
public $tags;
|
||||
public $f_title;
|
||||
public $f_full_title;
|
||||
public $f_time;
|
||||
public $f_time_h;
|
||||
public $link;
|
||||
public $f_link;
|
||||
public $f_codec;
|
||||
|
@ -60,10 +64,28 @@ class Video extends database_object implements media
|
|||
$this->$key = $value;
|
||||
}
|
||||
|
||||
$data = pathinfo($this->file);
|
||||
$this->type = strtolower($data['extension']);
|
||||
|
||||
return true;
|
||||
|
||||
} // Constructor
|
||||
|
||||
public static function create_from_id($video_id)
|
||||
{
|
||||
$dtypes = self::get_derived_types();
|
||||
foreach ($dtypes as $dtype) {
|
||||
$sql = "SELECT `id` FROM `" . strtolower($dtype) . "` WHERE `id` = ?";
|
||||
$db_results = Dba::read($sql, array($video_id));
|
||||
if ($results = Dba::fetch_assoc($db_results)) {
|
||||
if ($results['id']) {
|
||||
return new $dtype($video_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
return new Video($video_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* build_cache
|
||||
* Build a cache based on the array of ids passed, saves lots of little queries
|
||||
|
@ -90,6 +112,7 @@ class Video extends database_object implements media
|
|||
public function format()
|
||||
{
|
||||
$this->f_title = scrub_out($this->title);
|
||||
$this->f_full_title = $this->f_title;
|
||||
$this->link = AmpConfig::get('web_path') . "/video.php?action=show_video&video_id=" . $this->id;
|
||||
if (strtolower(get_class($this)) != 'video') {
|
||||
$this->link .= '&type=' . get_class($this);
|
||||
|
@ -97,7 +120,19 @@ class Video extends database_object implements media
|
|||
$this->f_link = "<a href=\"" . $this->link . "\" title=\"" . scrub_out($this->f_title) . "\"> " . scrub_out($this->f_title) . "</a>";
|
||||
$this->f_codec = $this->video_codec . ' / ' . $this->audio_codec;
|
||||
$this->f_resolution = $this->resolution_x . 'x' . $this->resolution_y;
|
||||
$this->f_tags = '';
|
||||
|
||||
// Format the Time
|
||||
$min = floor($this->time/60);
|
||||
$sec = sprintf("%02d", ($this->time%60));
|
||||
$this->f_time = $min . ":" . $sec;
|
||||
$hour = sprintf("%02d", floor($min/60));
|
||||
$min_h = sprintf("%02d", ($min%60));
|
||||
$this->f_time_h = $hour . ":" . $min_h . ":" . $sec;
|
||||
|
||||
// Get the top tags
|
||||
$this->tags = Tag::get_top_tags('video', $this->id);
|
||||
$this->f_tags = Tag::get_display($this->tags, true, 'video');
|
||||
|
||||
$this->f_length = floor($this->time/60) . ' ' . T_('minutes');
|
||||
$this->f_file = $this->f_title . '.' . $this->type;
|
||||
if ($this->release_date) {
|
||||
|
@ -138,7 +173,7 @@ class Video extends database_object implements media
|
|||
|
||||
if (!$video->id) { return false; }
|
||||
|
||||
$uid = intval($GLOBALS['user']->id);
|
||||
$uid = $GLOBALS['user']->id ? scrub_out($GLOBALS['user']->id) : '-1';
|
||||
$oid = intval($video->id);
|
||||
|
||||
$url = Stream::get_base_url() . "type=video&uid=" . $uid . "&oid=" . $oid;
|
||||
|
@ -157,17 +192,100 @@ class Video extends database_object implements media
|
|||
return false;
|
||||
}
|
||||
|
||||
private static function get_derived_types()
|
||||
{
|
||||
return array('TVShow_Episode', 'Movie', 'Clip', 'Personal_Video');
|
||||
}
|
||||
|
||||
public static function validate_type($type)
|
||||
{
|
||||
switch (strtolower($type)) {
|
||||
case 'tvshow_episode':
|
||||
case 'movie':
|
||||
case 'clip':
|
||||
case 'personal_video':
|
||||
$dtypes = self::get_derived_types();
|
||||
foreach ($dtypes as $dtype) {
|
||||
if (strtolower($type) == strtolower($dtype))
|
||||
return $type;
|
||||
}
|
||||
|
||||
return 'Video';
|
||||
}
|
||||
|
||||
/**
|
||||
* type_to_mime
|
||||
*
|
||||
* Returns the mime type for the specified file extension/type
|
||||
*/
|
||||
public static function type_to_mime($type)
|
||||
{
|
||||
// FIXME: This should really be done the other way around.
|
||||
// Store the mime type in the database, and provide a function
|
||||
// to make it a human-friendly type.
|
||||
switch ($type) {
|
||||
case 'avi':
|
||||
return 'video/avi';
|
||||
case 'ogg':
|
||||
return 'application/ogg';
|
||||
case 'wmv':
|
||||
return 'audio/x-ms-wmv';
|
||||
case 'mp4':
|
||||
case 'm4v':
|
||||
return 'video/mp4';
|
||||
case 'mkv':
|
||||
return 'video/x-matroska';
|
||||
default:
|
||||
return 'Video';
|
||||
return 'video/mpeg';
|
||||
}
|
||||
}
|
||||
|
||||
public static function insert($data, $gtypes = array(), $options = array())
|
||||
{
|
||||
$rezx = intval($data['resolution_x']);
|
||||
$rezy = intval($data['resolution_y']);
|
||||
$release_date = intval($data['release_date']);
|
||||
$tags = $data['genre'];
|
||||
|
||||
$sql = "INSERT INTO `video` (`file`,`catalog`,`title`,`video_codec`,`audio_codec`,`resolution_x`,`resolution_y`,`size`,`time`,`mime`,`release_date`,`addition_time`) " .
|
||||
" VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
|
||||
$params = array($data['file'], $data['catalog'], $data['title'], $data['video_codec'], $data['audio_codec'], $rezx, $rezy, $data['size'], $data['time'], $data['mime'], $release_date, time());
|
||||
Dba::write($sql, $params);
|
||||
$vid = Dba::insert_id();
|
||||
|
||||
if (is_array($tags)) {
|
||||
foreach ($tags as $tag) {
|
||||
$tag = trim($tag);
|
||||
if (!empty($tag)) {
|
||||
Tag::add('video', $vid, $tag, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($data['art'] && $options['gather_art']) {
|
||||
$art = new Art($vid, 'video');
|
||||
$art->insert_url($data['art']);
|
||||
}
|
||||
|
||||
$data['id'] = $vid;
|
||||
self::insert_video_type($data, $gtypes, $options);
|
||||
}
|
||||
|
||||
private static function insert_video_type($data, $gtypes, $options = array())
|
||||
{
|
||||
if (count($gtypes) > 0) {
|
||||
$gtype = $gtypes[0];
|
||||
switch ($gtype) {
|
||||
case 'tvshow':
|
||||
return TVShow_Episode::insert($data, $options);
|
||||
case 'movie':
|
||||
return Movie::insert($data, $options);
|
||||
case 'clip':
|
||||
return Clip::insert($data, $options);
|
||||
case 'personal_video':
|
||||
return Personal_Video::insert($data, $options);
|
||||
default:
|
||||
// Do nothing, video entry already created and no additional data for now
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return $data['id'];
|
||||
}
|
||||
|
||||
} // end Video class
|
||||
|
|
|
@ -342,7 +342,7 @@ class XML_Data
|
|||
$rating = new Rating($album_id,'album');
|
||||
|
||||
// Build the Art URL, include session
|
||||
$art_url = AmpConfig::get('web_path') . '/image.php?id=' . $album->id . '&auth=' . scrub_out($_REQUEST['auth']);
|
||||
$art_url = AmpConfig::get('web_path') . '/image.php?object_id=' . $album->id . '&object_type=album&auth=' . scrub_out($_REQUEST['auth']);
|
||||
|
||||
$string .= "<album id=\"" . $album->id . "\">\n" .
|
||||
"\t<name><![CDATA[" . $album->name . "]]></name>\n";
|
||||
|
|
|
@ -104,7 +104,6 @@ require_once $prefix . '/modules/getid3/getid3.php';
|
|||
require_once $prefix . '/modules/phpmailer/class.phpmailer.php';
|
||||
require_once $prefix . '/modules/phpmailer/class.smtp.php';
|
||||
require_once $prefix . '/modules/infotools/AmazonSearchEngine.class.php';
|
||||
require_once $prefix . '/modules/infotools/lastfm.class.php';
|
||||
require_once $prefix . '/modules/musicbrainz/MusicBrainz.php';
|
||||
require_once $prefix . '/modules/musicbrainz/Exception.php';
|
||||
require_once $prefix . '/modules/musicbrainz/Clients/MbClient.php';
|
||||
|
|
|
@ -19,8 +19,7 @@ use Tmdb\Client;
|
|||
* Class AbstractApi
|
||||
* @package Tmdb\Api
|
||||
*/
|
||||
abstract class AbstractApi
|
||||
implements ApiInterface
|
||||
abstract class AbstractApi implements ApiInterface
|
||||
{
|
||||
/**
|
||||
* The client
|
||||
|
@ -42,9 +41,9 @@ abstract class AbstractApi
|
|||
/**
|
||||
* Send a GET request
|
||||
*
|
||||
* @param string $path
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @param string $path
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @return mixed
|
||||
*/
|
||||
public function get($path, array $parameters = array(), $headers = array())
|
||||
|
@ -53,6 +52,7 @@ abstract class AbstractApi
|
|||
* @var Response $response
|
||||
*/
|
||||
$response = $this->client->getHttpClient()->get($path, $parameters, $headers);
|
||||
|
||||
return $response->json();
|
||||
}
|
||||
|
||||
|
@ -60,8 +60,8 @@ abstract class AbstractApi
|
|||
* Send a HEAD request
|
||||
*
|
||||
* @param $path
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @return mixed
|
||||
*/
|
||||
public function head($path, array $parameters = array(), $headers = array())
|
||||
|
@ -70,6 +70,7 @@ abstract class AbstractApi
|
|||
* @var Response $response
|
||||
*/
|
||||
$response = $this->client->getHttpClient()->head($path, $parameters, $headers);
|
||||
|
||||
return $response->json();
|
||||
}
|
||||
|
||||
|
@ -77,9 +78,9 @@ abstract class AbstractApi
|
|||
* Send a POST request
|
||||
*
|
||||
* @param $path
|
||||
* @param null $postBody
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @param null $postBody
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @return mixed
|
||||
*/
|
||||
public function post($path, $postBody = null, array $parameters = array(), $headers = array())
|
||||
|
@ -88,6 +89,7 @@ abstract class AbstractApi
|
|||
* @var Response $response
|
||||
*/
|
||||
$response = $this->client->getHttpClient()->post($path, $postBody, $parameters, $headers);
|
||||
|
||||
return $response->json();
|
||||
}
|
||||
|
||||
|
@ -95,9 +97,9 @@ abstract class AbstractApi
|
|||
* Send a POST request but json_encode the post body in the request
|
||||
*
|
||||
* @param $path
|
||||
* @param null $postBody
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @param null $postBody
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @return mixed
|
||||
*/
|
||||
public function postJson($path, $postBody = null, array $parameters = array(), $headers = array())
|
||||
|
@ -110,6 +112,7 @@ abstract class AbstractApi
|
|||
}
|
||||
|
||||
$response = $this->client->getHttpClient()->postJson($path, $postBody, $parameters, $headers);
|
||||
|
||||
return $response->json();
|
||||
}
|
||||
|
||||
|
@ -117,9 +120,9 @@ abstract class AbstractApi
|
|||
* Send a PUT request
|
||||
*
|
||||
* @param $path
|
||||
* @param null $body
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @param null $body
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @return mixed
|
||||
*/
|
||||
public function put($path, $body = null, array $parameters = array(), $headers = array())
|
||||
|
@ -128,6 +131,7 @@ abstract class AbstractApi
|
|||
* @var Response $response
|
||||
*/
|
||||
$response = $this->client->getHttpClient()->put($path, $body, $parameters, $headers);
|
||||
|
||||
return $response->json();
|
||||
}
|
||||
|
||||
|
@ -135,9 +139,9 @@ abstract class AbstractApi
|
|||
* Send a DELETE request
|
||||
*
|
||||
* @param $path
|
||||
* @param null $body
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @param null $body
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @return mixed
|
||||
*/
|
||||
public function delete($path, $body = null, array $parameters = array(), $headers = array())
|
||||
|
@ -146,6 +150,7 @@ abstract class AbstractApi
|
|||
* @var Response $response
|
||||
*/
|
||||
$response = $this->client->getHttpClient()->delete($path, $body, $parameters, $headers);
|
||||
|
||||
return $response->json();
|
||||
}
|
||||
|
||||
|
@ -153,9 +158,9 @@ abstract class AbstractApi
|
|||
* Send a PATCH request
|
||||
*
|
||||
* @param $path
|
||||
* @param null $body
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @param null $body
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @return mixed
|
||||
*/
|
||||
public function patch($path, $body = null, array $parameters = array(), $headers = array())
|
||||
|
@ -164,6 +169,7 @@ abstract class AbstractApi
|
|||
* @var Response $response
|
||||
*/
|
||||
$response = $this->client->getHttpClient()->patch($path, $body, $parameters, $headers);
|
||||
|
||||
return $response->json();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,14 +17,13 @@ namespace Tmdb\Api;
|
|||
* @package Tmdb\Api
|
||||
* @see http://docs.themoviedb.apiary.io/#account
|
||||
*/
|
||||
class Account
|
||||
extends AbstractApi
|
||||
class Account extends AbstractApi
|
||||
{
|
||||
/**
|
||||
* Get the basic information for an account. You will need to have a valid session id.
|
||||
*
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @return mixed
|
||||
*/
|
||||
public function getAccount(array $parameters = array(), array $headers = array())
|
||||
|
@ -35,9 +34,9 @@ class Account
|
|||
/**
|
||||
* Get the lists that you have created and marked as a favorite.
|
||||
*
|
||||
* @param integer $accountId
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @param integer $accountId
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @return mixed
|
||||
*/
|
||||
public function getLists($accountId, array $parameters = array(), array $headers = array())
|
||||
|
@ -48,9 +47,9 @@ class Account
|
|||
/**
|
||||
* Get the list of favorite movies for an account.
|
||||
*
|
||||
* @param integer $accountId
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @param integer $accountId
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @return mixed
|
||||
*/
|
||||
public function getFavoriteMovies($accountId, array $parameters = array(), array $headers = array())
|
||||
|
@ -61,9 +60,9 @@ class Account
|
|||
/**
|
||||
* Add or remove a movie to an accounts favorite list.
|
||||
*
|
||||
* @param integer $accountId
|
||||
* @param integer $movieId
|
||||
* @param boolean $isFavorite
|
||||
* @param integer $accountId
|
||||
* @param integer $movieId
|
||||
* @param boolean $isFavorite
|
||||
* @return mixed
|
||||
*/
|
||||
public function favorite($accountId, $movieId, $isFavorite = true)
|
||||
|
@ -77,9 +76,9 @@ class Account
|
|||
/**
|
||||
* Get the list of rated movies (and associated rating) for an account.
|
||||
*
|
||||
* @param integer $accountId
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @param integer $accountId
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @return mixed
|
||||
*/
|
||||
public function getRatedMovies($accountId, array $parameters = array(), array $headers = array())
|
||||
|
@ -90,9 +89,9 @@ class Account
|
|||
/**
|
||||
* Get the list of movies on an accounts watchlist.
|
||||
*
|
||||
* @param integer $accountId
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @param integer $accountId
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @return mixed
|
||||
*/
|
||||
public function getMovieWatchlist($accountId, array $parameters = array(), array $headers = array())
|
||||
|
@ -103,9 +102,9 @@ class Account
|
|||
/**
|
||||
* Add or remove a movie to an accounts watch list.
|
||||
*
|
||||
* @param integer $accountId
|
||||
* @param integer $movieId
|
||||
* @param boolean $isOnWatchlist
|
||||
* @param integer $accountId
|
||||
* @param integer $movieId
|
||||
* @param boolean $isOnWatchlist
|
||||
* @return mixed
|
||||
*/
|
||||
public function watchlist($accountId, $movieId, $isOnWatchlist = true)
|
||||
|
|
|
@ -16,5 +16,6 @@ namespace Tmdb\Api;
|
|||
* Interface ApiInterface
|
||||
* @package Tmdb\Api
|
||||
*/
|
||||
interface ApiInterface {
|
||||
interface ApiInterface
|
||||
{
|
||||
}
|
||||
|
|
|
@ -12,16 +12,15 @@
|
|||
*/
|
||||
namespace Tmdb\Api;
|
||||
|
||||
use Symfony\Component\Yaml\Exception\RuntimeException;
|
||||
use Tmdb\Exception\UnauthorizedRequestTokenException;
|
||||
use Tmdb\RequestToken;
|
||||
|
||||
/**
|
||||
* Class Authentication
|
||||
* @package Tmdb\Api
|
||||
* @see http://docs.themoviedb.apiary.io/#authentication
|
||||
*/
|
||||
class Authentication
|
||||
extends AbstractApi
|
||||
class Authentication extends AbstractApi
|
||||
{
|
||||
const REQUEST_TOKEN_URI = 'https://www.themoviedb.org/authenticate';
|
||||
|
||||
|
@ -46,30 +45,93 @@ class Authentication
|
|||
*/
|
||||
public function authenticateRequestToken($token)
|
||||
{
|
||||
//@codeCoverageIgnoreStart
|
||||
header(sprintf(
|
||||
'Location: %s/%s',
|
||||
self::REQUEST_TOKEN_URI,
|
||||
$token
|
||||
));
|
||||
//@codeCoverageIgnoreEnd
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is used to generate a session id for user based authentication.
|
||||
* A session id is required in order to use any of the write methods.
|
||||
*
|
||||
* @param string $requestToken
|
||||
* @param string $requestToken
|
||||
* @throws UnauthorizedRequestTokenException
|
||||
* @return mixed
|
||||
*/
|
||||
public function getNewSession($requestToken)
|
||||
{
|
||||
if ($requestToken instanceof RequestToken) {
|
||||
$requestToken = $requestToken->getToken();
|
||||
}
|
||||
|
||||
try {
|
||||
return $this->get('authentication/session/new', array('request_token' => $requestToken));
|
||||
}
|
||||
catch(\Exception $e) {
|
||||
|
||||
//@codeCoverageIgnoreStart
|
||||
} catch (\Exception $e) {
|
||||
if ($e->getCode() == 401) {
|
||||
throw new UnauthorizedRequestTokenException("The request token has not been validated yet.");
|
||||
}
|
||||
//@codeCoverageIgnoreEnd
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to validate the request_token and obtain a session_token
|
||||
*
|
||||
* @param $requestToken
|
||||
* @param $username
|
||||
* @param $password
|
||||
* @return mixed
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public function getSessionTokenWithLogin($requestToken, $username, $password)
|
||||
{
|
||||
if ($requestToken instanceof RequestToken) {
|
||||
$requestToken = $requestToken->getToken();
|
||||
}
|
||||
|
||||
$validatedRequestToken = $this->validateRequestTokenWithLogin($requestToken, $username, $password);
|
||||
|
||||
if (!$validatedRequestToken['success']) {
|
||||
throw new \InvalidArgumentException('Unable to validate the request_token, please check your credentials.');
|
||||
}
|
||||
|
||||
return $this->getNewSession($validatedRequestToken['request_token']);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is used to generate a session id for user based authentication.
|
||||
* A session id is required in order to use any of the write methods.
|
||||
*
|
||||
* @param string $requestToken
|
||||
* @param string $username
|
||||
* @param string $password
|
||||
* @throws UnauthorizedRequestTokenException
|
||||
* @return mixed
|
||||
*/
|
||||
public function validateRequestTokenWithLogin($requestToken, $username, $password)
|
||||
{
|
||||
if ($requestToken instanceof RequestToken) {
|
||||
$requestToken = $requestToken->getToken();
|
||||
}
|
||||
|
||||
try {
|
||||
return $this->get('authentication/token/validate_with_login', array(
|
||||
'username' => $username,
|
||||
'password' => $password,
|
||||
'request_token' => $requestToken
|
||||
));
|
||||
//@codeCoverageIgnoreStart
|
||||
} catch (\Exception $e) {
|
||||
if ($e->getCode() == 401) {
|
||||
throw new UnauthorizedRequestTokenException("The request token has not been validated yet.");
|
||||
}
|
||||
//@codeCoverageIgnoreEnd
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -80,7 +142,8 @@ class Authentication
|
|||
* You should only generate a single guest session per user (or device)
|
||||
* as you will be able to attach the ratings to a TMDb user account in the future.
|
||||
*
|
||||
* There is also IP limits in place so you should always make sure it's the end user doing the guest session actions.
|
||||
* There is also IP limits in place so you should always make sure it's the end user
|
||||
* doing the guest session actions.
|
||||
*
|
||||
* If a guest session is not used for the first time within 24 hours, it will be automatically discarded.
|
||||
*
|
||||
|
|
|
@ -17,16 +17,16 @@ namespace Tmdb\Api;
|
|||
* @package Tmdb\Api
|
||||
* @see http://docs.themoviedb.apiary.io/#certifications
|
||||
*/
|
||||
class Certifications
|
||||
extends AbstractApi
|
||||
class Certifications extends AbstractApi
|
||||
{
|
||||
/**
|
||||
* Get the list of supported certifications for movies.
|
||||
*
|
||||
* These can be used in conjunction with the certification_country and certification.lte parameters when using discover.
|
||||
* These can be used in conjunction with the certification_country and
|
||||
* certification.lte parameters when using discover.
|
||||
*
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @return mixed
|
||||
*/
|
||||
public function getMovieList(array $parameters = array(), array $headers = array())
|
||||
|
|
|
@ -17,8 +17,7 @@ namespace Tmdb\Api;
|
|||
* @package Tmdb\Api
|
||||
* http://docs.themoviedb.apiary.io/#changes
|
||||
*/
|
||||
class Changes
|
||||
extends AbstractApi
|
||||
class Changes extends AbstractApi
|
||||
{
|
||||
/**
|
||||
* Get a list of movie ids that have been edited.
|
||||
|
@ -31,8 +30,8 @@ class Changes
|
|||
* Please note that the change log system to support this was changed
|
||||
* on October 5, 2012 and will only show movies that have been edited since.
|
||||
*
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @return mixed
|
||||
*/
|
||||
public function getMovieChanges(array $parameters = array(), array $headers = array())
|
||||
|
@ -51,8 +50,8 @@ class Changes
|
|||
* Please note that the change log system to support this was changed
|
||||
* on October 5, 2012 and will only show movies that have been edited since.
|
||||
*
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @return mixed
|
||||
*/
|
||||
public function getPersonChanges(array $parameters = array(), array $headers = array())
|
||||
|
|
|
@ -17,8 +17,7 @@ namespace Tmdb\Api;
|
|||
* @package Tmdb\Api
|
||||
* @see http://docs.themoviedb.apiary.io/#collections
|
||||
*/
|
||||
class Collections
|
||||
extends AbstractApi
|
||||
class Collections extends AbstractApi
|
||||
{
|
||||
/**
|
||||
* Get the basic collection information for a specific collection id.
|
||||
|
@ -30,8 +29,8 @@ class Collections
|
|||
* If you would like to sort them yourself you can use the provided release_date.
|
||||
*
|
||||
* @param $collection_id
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @return mixed
|
||||
*/
|
||||
public function getCollection($collection_id, array $parameters = array(), array $headers = array())
|
||||
|
@ -43,8 +42,8 @@ class Collections
|
|||
* Get all of the images for a particular collection by collection id.
|
||||
*
|
||||
* @param $collection_id
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @return mixed
|
||||
*/
|
||||
public function getImages($collection_id, array $parameters = array(), array $headers = array())
|
||||
|
|
|
@ -17,15 +17,14 @@ namespace Tmdb\Api;
|
|||
* @package Tmdb\Api
|
||||
* @see http://docs.themoviedb.apiary.io/#companies
|
||||
*/
|
||||
class Companies
|
||||
extends AbstractApi
|
||||
class Companies extends AbstractApi
|
||||
{
|
||||
/**
|
||||
* This method is used to retrieve all of the basic information about a company.
|
||||
*
|
||||
* @param $company_id
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @return mixed
|
||||
*/
|
||||
public function getCompany($company_id, array $parameters = array(), array $headers = array())
|
||||
|
@ -36,9 +35,9 @@ class Companies
|
|||
/**
|
||||
* Get the list of movies associated with a particular company.
|
||||
*
|
||||
* @param integer $company_id
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @param integer $company_id
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @return mixed
|
||||
*/
|
||||
public function getMovies($company_id, array $parameters = array(), array $headers = array())
|
||||
|
|
|
@ -18,8 +18,7 @@ namespace Tmdb\Api;
|
|||
*
|
||||
* @see http://docs.themoviedb.apiary.io/#configuration
|
||||
*/
|
||||
class Configuration
|
||||
extends AbstractApi
|
||||
class Configuration extends AbstractApi
|
||||
{
|
||||
/**
|
||||
* Get the system wide configuration information.
|
||||
|
@ -38,7 +37,7 @@ class Configuration
|
|||
*
|
||||
* http://d3gtl9l2a4fn1j.cloudfront.net/t/p/w500/8uO0gUM8aNqYLs1OsTBQiXu0fEv.jpg
|
||||
*
|
||||
* @param array $headers
|
||||
* @param array $headers
|
||||
* @return mixed
|
||||
*/
|
||||
public function getConfiguration(array $headers = array())
|
||||
|
|
|
@ -17,12 +17,14 @@ namespace Tmdb\Api;
|
|||
* @package Tmdb\Api
|
||||
* @see http://docs.themoviedb.apiary.io/#credits
|
||||
*/
|
||||
class Credits
|
||||
extends AbstractApi
|
||||
class Credits extends AbstractApi
|
||||
{
|
||||
/**
|
||||
* Get the detailed information about a particular credit record. This is currently only supported with the new credit model found in TV.
|
||||
* These ids can be found from any TV credit response as well as the tv_credits and combined_credits methods for people.
|
||||
* Get the detailed information about a particular credit record.
|
||||
*
|
||||
* This is currently only supported with the new credit model found in TV.
|
||||
* These ids can be found from any TV credit response as well as
|
||||
* the tv_credits and combined_credits methods for people.
|
||||
*
|
||||
* The episodes object returns a list of episodes and are generally going to be guest stars.
|
||||
* The season array will return a list of season numbers.
|
||||
|
@ -31,8 +33,8 @@ class Credits
|
|||
* and are assumed to be "season regulars".
|
||||
*
|
||||
* @param $credit_id
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @return mixed
|
||||
*/
|
||||
public function getCredit($credit_id, array $parameters = array(), array $headers = array())
|
||||
|
|
|
@ -17,14 +17,13 @@ namespace Tmdb\Api;
|
|||
* @package Tmdb\Api
|
||||
* @see http://docs.themoviedb.apiary.io/#discover
|
||||
*/
|
||||
class Discover
|
||||
extends AbstractApi
|
||||
class Discover extends AbstractApi
|
||||
{
|
||||
/**
|
||||
* Discover movies by different types of data like average rating, number of votes, genres and certifications.
|
||||
*
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @return mixed
|
||||
*/
|
||||
public function discoverMovies(array $parameters = array(), array $headers = array())
|
||||
|
@ -33,10 +32,11 @@ class Discover
|
|||
}
|
||||
|
||||
/**
|
||||
* Discover TV shows by different types of data like average rating, number of votes, genres, the network they aired on and air dates.
|
||||
* Discover TV shows by different types of data like average rating, number of votes, genres,
|
||||
* the network they aired on and air dates.
|
||||
*
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @return mixed
|
||||
*/
|
||||
public function discoverTv(array $parameters = array(), array $headers = array())
|
||||
|
|
|
@ -17,21 +17,24 @@ namespace Tmdb\Api;
|
|||
* @package Tmdb\Api
|
||||
* @see http://docs.themoviedb.apiary.io/#find
|
||||
*/
|
||||
class Find
|
||||
extends AbstractApi
|
||||
class Find extends AbstractApi
|
||||
{
|
||||
/**
|
||||
* The find method makes it easy to search for objects in our database by an external id. For instance, an IMDB ID. This will search all objects (movies, TV shows and people) and return the results in a single response. TV season and TV episode searches will be supported shortly.
|
||||
* The find method makes it easy to search for objects in our database by an external id.
|
||||
*
|
||||
* For instance, an IMDB ID. This will search all objects (movies, TV shows and people)
|
||||
* and return the results in a single response.
|
||||
*
|
||||
* TV season and TV episode searches will be supported shortly.
|
||||
* The supported external sources for each object are as follows:
|
||||
*
|
||||
* Movies: imdb_id
|
||||
* People: imdb_id, freebase_mid, freebase_id, tvrage_id
|
||||
* TV Series: imdb_id, freebase_mid, freebase_id, tvdb_id, tvrage_id
|
||||
*
|
||||
* @param string $id
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @param string $id
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @return mixed
|
||||
*/
|
||||
public function find($id, array $parameters = array(), array $headers = array())
|
||||
|
|
|
@ -17,15 +17,14 @@ namespace Tmdb\Api;
|
|||
* @package Tmdb\Api
|
||||
* @see http://docs.themoviedb.apiary.io/#genres
|
||||
*/
|
||||
class Genres
|
||||
extends AbstractApi
|
||||
class Genres extends AbstractApi
|
||||
{
|
||||
/**
|
||||
* Get the list of genres, and return one by id
|
||||
*
|
||||
* @param integer $id
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @param integer $id
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @return mixed
|
||||
*/
|
||||
public function getGenre($id, array $parameters = array(), array $headers = array())
|
||||
|
@ -42,8 +41,8 @@ class Genres
|
|||
/**
|
||||
* Get the list of genres.
|
||||
*
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @return mixed
|
||||
*/
|
||||
public function getGenres(array $parameters = array(), array $headers = array())
|
||||
|
@ -55,8 +54,8 @@ class Genres
|
|||
* Get the list of movies for a particular genre by id. By default, only movies with 10 or more votes are included.
|
||||
*
|
||||
* @param $genre_id
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @return mixed
|
||||
*/
|
||||
public function getMovies($genre_id, array $parameters = array(), array $headers = array())
|
||||
|
@ -65,15 +64,16 @@ class Genres
|
|||
}
|
||||
|
||||
/**
|
||||
* @param integer $id
|
||||
* @param array $data
|
||||
* @param integer $id
|
||||
* @param array $data
|
||||
* @return mixed
|
||||
*/
|
||||
private function extractGenreByIdFromResponse($id, array $data = array())
|
||||
{
|
||||
foreach($data as $genre) {
|
||||
if ($id == $genre['id'])
|
||||
foreach ($data as $genre) {
|
||||
if ($id == $genre['id']) {
|
||||
return $genre;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
|
|
42
modules/Tmdb/Api/GuestSession.php
Normal file
42
modules/Tmdb/Api/GuestSession.php
Normal file
|
@ -0,0 +1,42 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of the Tmdb PHP API created by Michael Roterman.
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* @package Tmdb
|
||||
* @author Michael Roterman <michael@wtfz.net>
|
||||
* @copyright (c) 2013, Michael Roterman
|
||||
* @version 0.0.1
|
||||
*/
|
||||
namespace Tmdb\Api;
|
||||
use Tmdb\Exception\MissingSessionTokenException;
|
||||
use Tmdb\SessionToken;
|
||||
|
||||
/**
|
||||
* Class GuestSession
|
||||
* @package Tmdb\Api
|
||||
* @see http://docs.themoviedb.apiary.io/#guestsessions
|
||||
*/
|
||||
class GuestSession extends AbstractApi
|
||||
{
|
||||
/**
|
||||
* Get a list of rated movies for a specific guest session id.
|
||||
*
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @throws MissingSessionTokenException when the guest session token was not set on the client.
|
||||
* @return mixed
|
||||
*/
|
||||
public function getRatedMovies(array $parameters = array(), array $headers = array())
|
||||
{
|
||||
$sessionToken = $this->client->getSessionToken();
|
||||
|
||||
if (!$sessionToken instanceof SessionToken) {
|
||||
throw new MissingSessionTokenException('The guest session token was not set on the client.');
|
||||
}
|
||||
|
||||
return $this->get('guest_session/' . $sessionToken->getToken() . '/rated_movies', $parameters, $headers);
|
||||
}
|
||||
}
|
|
@ -17,14 +17,13 @@ namespace Tmdb\Api;
|
|||
* @package Tmdb\Api
|
||||
* @see http://docs.themoviedb.apiary.io/#jobs
|
||||
*/
|
||||
class Jobs
|
||||
extends AbstractApi
|
||||
class Jobs extends AbstractApi
|
||||
{
|
||||
/**
|
||||
* Get a list of valid jobs.
|
||||
*
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @return mixed
|
||||
*/
|
||||
public function getJobs(array $parameters = array(), array $headers = array())
|
||||
|
|
|
@ -17,15 +17,14 @@ namespace Tmdb\Api;
|
|||
* @package Tmdb\Api
|
||||
* @see http://docs.themoviedb.apiary.io/#keywords
|
||||
*/
|
||||
class Keywords
|
||||
extends AbstractApi
|
||||
class Keywords extends AbstractApi
|
||||
{
|
||||
/**
|
||||
* Get the basic information for a specific keyword id.
|
||||
*
|
||||
* @param int $keyword_id
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @param int $keyword_id
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @return mixed
|
||||
*/
|
||||
public function getKeyword($keyword_id, array $parameters = array(), array $headers = array())
|
||||
|
@ -36,9 +35,9 @@ class Keywords
|
|||
/**
|
||||
* Get the list of movies for a particular keyword by id.
|
||||
*
|
||||
* @param int $keyword_id
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @param int $keyword_id
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @return mixed
|
||||
*/
|
||||
public function getMovies($keyword_id, array $parameters = array(), array $headers = array())
|
||||
|
|
|
@ -17,15 +17,14 @@ namespace Tmdb\Api;
|
|||
* @package Tmdb\Api
|
||||
* @see http://docs.themoviedb.apiary.io/#lists
|
||||
*/
|
||||
class Lists
|
||||
extends AbstractApi
|
||||
class Lists extends AbstractApi
|
||||
{
|
||||
/**
|
||||
* Get a list by id.
|
||||
*
|
||||
* @param $list_id
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @return mixed
|
||||
*/
|
||||
public function getList($list_id, array $parameters = array(), array $headers = array())
|
||||
|
@ -36,10 +35,10 @@ class Lists
|
|||
/**
|
||||
* This method lets users create a new list. A valid session id is required.
|
||||
*
|
||||
* @param string $name
|
||||
* @param string $description
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @param string $name
|
||||
* @param string $description
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @return mixed
|
||||
*/
|
||||
public function createList($name, $description, array $parameters = array(), array $headers = array())
|
||||
|
@ -50,10 +49,10 @@ class Lists
|
|||
/**
|
||||
* Check to see if a movie ID is already added to a list.
|
||||
*
|
||||
* @param string $id
|
||||
* @param int $movieId
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @param string $id
|
||||
* @param int $movieId
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @return mixed
|
||||
*/
|
||||
public function getItemStatus($id, $movieId, array $parameters = array(), array $headers = array())
|
||||
|
@ -68,8 +67,8 @@ class Lists
|
|||
/**
|
||||
* This method lets users add new movies to a list that they created. A valid session id is required.
|
||||
*
|
||||
* @param string $id
|
||||
* @param string $mediaId
|
||||
* @param string $id
|
||||
* @param string $mediaId
|
||||
* @return mixed
|
||||
*/
|
||||
public function addMediaToList($id, $mediaId)
|
||||
|
@ -80,8 +79,8 @@ class Lists
|
|||
/**
|
||||
* This method lets users delete movies from a list that they created. A valid session id is required.
|
||||
*
|
||||
* @param string $id
|
||||
* @param string $mediaId
|
||||
* @param string $id
|
||||
* @param string $mediaId
|
||||
* @return mixed
|
||||
*/
|
||||
public function removeMediaFromList($id, $mediaId)
|
||||
|
@ -92,11 +91,30 @@ class Lists
|
|||
/**
|
||||
* This method lets users delete a list that they created. A valid session id is required.
|
||||
*
|
||||
* @param string $id
|
||||
* @param string $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function deleteList($id)
|
||||
{
|
||||
return $this->delete('list/' . $id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear all of the items within a list.
|
||||
*
|
||||
* This is a irreversible action and should be treated with caution.
|
||||
* A valid session id is required.
|
||||
*
|
||||
* @param string $id
|
||||
* @param boolean $confirm
|
||||
* @return mixed
|
||||
*/
|
||||
public function clearList($id, $confirm)
|
||||
{
|
||||
return $this->post(sprintf(
|
||||
'list/%s/clear?confirm=%s',
|
||||
$id,
|
||||
(bool) $confirm === true ? 'true':'false'
|
||||
));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,15 +17,14 @@ namespace Tmdb\Api;
|
|||
* @package Tmdb\Api
|
||||
* @see http://docs.themoviedb.apiary.io/#movies
|
||||
*/
|
||||
class Movies
|
||||
extends AbstractApi
|
||||
class Movies extends AbstractApi
|
||||
{
|
||||
/**
|
||||
* Get the basic movie information for a specific movie id.
|
||||
*
|
||||
* @param $movie_id
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @return mixed
|
||||
*/
|
||||
public function getMovie($movie_id, array $parameters = array(), array $headers = array())
|
||||
|
@ -37,8 +36,8 @@ class Movies
|
|||
* Get the alternative titles for a specific movie id.
|
||||
*
|
||||
* @param $movie_id
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @return mixed
|
||||
*/
|
||||
public function getAlternativeTitles($movie_id, array $parameters = array(), array $headers = array())
|
||||
|
@ -50,8 +49,8 @@ class Movies
|
|||
* Get the cast and crew information for a specific movie id.
|
||||
*
|
||||
* @param $movie_id
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @return mixed
|
||||
*/
|
||||
public function getCredits($movie_id, array $parameters = array(), array $headers = array())
|
||||
|
@ -63,8 +62,8 @@ class Movies
|
|||
* Get the images (posters and backdrops) for a specific movie id.
|
||||
*
|
||||
* @param $movie_id
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @return mixed
|
||||
*/
|
||||
public function getImages($movie_id, array $parameters = array(), array $headers = array())
|
||||
|
@ -76,8 +75,8 @@ class Movies
|
|||
* Get the plot keywords for a specific movie id.
|
||||
*
|
||||
* @param $movie_id
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @return mixed
|
||||
*/
|
||||
public function getKeywords($movie_id, array $parameters = array(), array $headers = array())
|
||||
|
@ -89,8 +88,8 @@ class Movies
|
|||
* Get the release date by country for a specific movie id.
|
||||
*
|
||||
* @param $movie_id
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @return mixed
|
||||
*/
|
||||
public function getReleases($movie_id, array $parameters = array(), array $headers = array())
|
||||
|
@ -101,9 +100,10 @@ class Movies
|
|||
/**
|
||||
* Get the trailers for a specific movie id.
|
||||
*
|
||||
* @deprecated TMDB changed the way of requesting trailers, see getVideos instead!
|
||||
* @param $movie_id
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @return mixed
|
||||
*/
|
||||
public function getTrailers($movie_id, array $parameters = array(), array $headers = array())
|
||||
|
@ -115,8 +115,8 @@ class Movies
|
|||
* Get the translations for a specific movie id.
|
||||
*
|
||||
* @param $movie_id
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @return mixed
|
||||
*/
|
||||
public function getTranslations($movie_id, array $parameters = array(), array $headers = array())
|
||||
|
@ -128,8 +128,8 @@ class Movies
|
|||
* Get the similar movies for a specific movie id.
|
||||
*
|
||||
* @param $movie_id
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @return mixed
|
||||
*/
|
||||
public function getSimilarMovies($movie_id, array $parameters = array(), array $headers = array())
|
||||
|
@ -141,8 +141,8 @@ class Movies
|
|||
* Get the reviews for a particular movie id.
|
||||
*
|
||||
* @param $movie_id
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @return mixed
|
||||
*/
|
||||
public function getReviews($movie_id, array $parameters = array(), array $headers = array())
|
||||
|
@ -154,8 +154,8 @@ class Movies
|
|||
* Get the lists that the movie belongs to.
|
||||
*
|
||||
* @param $movie_id
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @return mixed
|
||||
*/
|
||||
public function getLists($movie_id, array $parameters = array(), array $headers = array())
|
||||
|
@ -167,8 +167,8 @@ class Movies
|
|||
* Get the changes for a specific movie id.
|
||||
*
|
||||
* @param $movie_id
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @return mixed
|
||||
*/
|
||||
public function getChanges($movie_id, array $parameters = array(), array $headers = array())
|
||||
|
@ -179,8 +179,8 @@ class Movies
|
|||
/**
|
||||
* Get the latest movie id.
|
||||
*
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @return mixed
|
||||
*/
|
||||
public function getLatest(array $parameters = array(), array $headers = array())
|
||||
|
@ -189,10 +189,11 @@ class Movies
|
|||
}
|
||||
|
||||
/**
|
||||
* Get the list of upcoming movies. This list refreshes every day. The maximum number of items this list will include is 100.
|
||||
* Get the list of upcoming movies. This list refreshes every day.
|
||||
* The maximum number of items this list will include is 100.
|
||||
*
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @return mixed
|
||||
*/
|
||||
public function getUpcoming(array $parameters = array(), array $headers = array())
|
||||
|
@ -201,10 +202,11 @@ class Movies
|
|||
}
|
||||
|
||||
/**
|
||||
* Get the list of movies playing in theatres. This list refreshes every day. The maximum number of items this list will include is 100.
|
||||
* Get the list of movies playing in theatres. This list refreshes every day.
|
||||
* The maximum number of items this list will include is 100.
|
||||
*
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @return mixed
|
||||
*/
|
||||
public function getNowPlaying(array $parameters = array(), array $headers = array())
|
||||
|
@ -213,10 +215,11 @@ class Movies
|
|||
}
|
||||
|
||||
/**
|
||||
* Get the list of popular movies on The Movie Database. This list refreshes every day.
|
||||
* Get the list of popular movies on The Movie Database.
|
||||
* This list refreshes every day.
|
||||
*
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @return mixed
|
||||
*/
|
||||
public function getPopular(array $parameters = array(), array $headers = array())
|
||||
|
@ -225,10 +228,11 @@ class Movies
|
|||
}
|
||||
|
||||
/**
|
||||
* Get the list of top rated movies. By default, this list will only include movies that have 10 or more votes. This list refreshes every day.
|
||||
* Get the list of top rated movies. By default, this list will only include
|
||||
* movies that have 10 or more votes. This list refreshes every day.
|
||||
*
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @return mixed
|
||||
*/
|
||||
public function getTopRated(array $parameters = array(), array $headers = array())
|
||||
|
@ -237,7 +241,8 @@ class Movies
|
|||
}
|
||||
|
||||
/**
|
||||
* This method lets users get the status of whether or not the movie has been rated or added to their favourite or watch lists.
|
||||
* This method lets users get the status of whether or not the movie has been rated
|
||||
* or added to their favourite or watch lists.
|
||||
*
|
||||
* A valid session id is required.
|
||||
*
|
||||
|
@ -259,4 +264,17 @@ class Movies
|
|||
{
|
||||
return $this->postJson('movie/' . $id . '/rating', array('value' => (float) $rating));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the videos (trailers, teasers, clips, etc...) for a specific movie id.
|
||||
*
|
||||
* @param $movie_id
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @return mixed
|
||||
*/
|
||||
public function getVideos($movie_id, array $parameters = array(), array $headers = array())
|
||||
{
|
||||
return $this->get('movie/' . $movie_id . '/videos', $parameters, $headers);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,8 +17,7 @@ namespace Tmdb\Api;
|
|||
* @package Tmdb\Api
|
||||
* @see http://docs.themoviedb.apiary.io/#networks
|
||||
*/
|
||||
class Networks
|
||||
extends AbstractApi
|
||||
class Networks extends AbstractApi
|
||||
{
|
||||
/**
|
||||
* This method is used to retrieve the basic information about a TV network.
|
||||
|
@ -26,9 +25,9 @@ class Networks
|
|||
* You can use this ID to search for TV shows with the discover.
|
||||
* At this time we don't have much but this will be fleshed out over time.
|
||||
*
|
||||
* @param int $network_id
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @param int $network_id
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @return mixed
|
||||
*/
|
||||
public function getNetwork($network_id, array $parameters = array(), array $headers = array())
|
||||
|
|
|
@ -17,15 +17,14 @@ namespace Tmdb\Api;
|
|||
* @package Tmdb\Api
|
||||
* @see http://docs.themoviedb.apiary.io/#people
|
||||
*/
|
||||
class People
|
||||
extends AbstractApi
|
||||
class People extends AbstractApi
|
||||
{
|
||||
/**
|
||||
* Get the general person information for a specific id.
|
||||
*
|
||||
* @param $person_id
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @return mixed
|
||||
*/
|
||||
public function getPerson($person_id, array $parameters = array(), array $headers = array())
|
||||
|
@ -37,8 +36,8 @@ class People
|
|||
* Get the credits for a specific person id.
|
||||
*
|
||||
* @param $person_id
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @return mixed
|
||||
*/
|
||||
public function getCredits($person_id, array $parameters = array(), array $headers = array())
|
||||
|
@ -50,8 +49,8 @@ class People
|
|||
* Get the movie credits for a specific person id.
|
||||
*
|
||||
* @param $person_id
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @return mixed
|
||||
*/
|
||||
public function getMovieCredits($person_id, array $parameters = array(), array $headers = array())
|
||||
|
@ -66,8 +65,8 @@ class People
|
|||
* This will provide details about which episode and/or season the credit is for.
|
||||
*
|
||||
* @param $person_id
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @return mixed
|
||||
*/
|
||||
public function getTvCredits($person_id, array $parameters = array(), array $headers = array())
|
||||
|
@ -82,8 +81,8 @@ class People
|
|||
* This will provide details about which episode and/or season the credit is for.
|
||||
*
|
||||
* @param $person_id
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @return mixed
|
||||
*/
|
||||
public function getCombinedCredits($person_id, array $parameters = array(), array $headers = array())
|
||||
|
@ -95,8 +94,8 @@ class People
|
|||
* Get the images for a specific person id.
|
||||
*
|
||||
* @param $person_id
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @return mixed
|
||||
*/
|
||||
public function getImages($person_id, array $parameters = array(), array $headers = array())
|
||||
|
@ -114,8 +113,8 @@ class People
|
|||
* The language is present on fields that are translatable.
|
||||
*
|
||||
* @param $person_id
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @return mixed
|
||||
*/
|
||||
public function getChanges($person_id, array $parameters = array(), array $headers = array())
|
||||
|
@ -127,8 +126,8 @@ class People
|
|||
* Get the external ids for a specific person id.
|
||||
*
|
||||
* @param $person_id
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @return mixed
|
||||
*/
|
||||
public function getExternalIds($person_id, array $parameters = array(), array $headers = array())
|
||||
|
@ -139,8 +138,8 @@ class People
|
|||
/**
|
||||
* Get the list of popular people on The Movie Database. This list refreshes every day.
|
||||
*
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @return mixed
|
||||
*/
|
||||
public function getPopular(array $parameters = array(), array $headers = array())
|
||||
|
|
|
@ -17,15 +17,14 @@ namespace Tmdb\Api;
|
|||
* @package Tmdb\Api
|
||||
* @see http://docs.themoviedb.apiary.io/#reviews
|
||||
*/
|
||||
class Reviews
|
||||
extends AbstractApi
|
||||
class Reviews extends AbstractApi
|
||||
{
|
||||
/**
|
||||
* Get the full details of a review by ID.
|
||||
*
|
||||
* @param $review_id
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @return mixed
|
||||
*/
|
||||
public function getReview($review_id, array $parameters = array(), array $headers = array())
|
||||
|
|
|
@ -17,15 +17,14 @@ namespace Tmdb\Api;
|
|||
* @package Tmdb\Api
|
||||
* @see http://docs.themoviedb.apiary.io/#search
|
||||
*/
|
||||
class Search
|
||||
extends AbstractApi
|
||||
class Search extends AbstractApi
|
||||
{
|
||||
/**
|
||||
* Search for movies by title.
|
||||
*
|
||||
* @param $query
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @return mixed
|
||||
*/
|
||||
public function searchMovies($query, array $parameters = array(), array $headers = array())
|
||||
|
@ -39,8 +38,8 @@ class Search
|
|||
* Search for collections by name.
|
||||
*
|
||||
* @param $query
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @return mixed
|
||||
*/
|
||||
public function searchCollection($query, array $parameters = array(), array $headers = array())
|
||||
|
@ -54,8 +53,8 @@ class Search
|
|||
* Search for TV shows by title.
|
||||
*
|
||||
* @param $query
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @return mixed
|
||||
*/
|
||||
public function searchTv($query, array $parameters = array(), array $headers = array())
|
||||
|
@ -69,8 +68,8 @@ class Search
|
|||
* Search for people by name.
|
||||
*
|
||||
* @param $query
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @return mixed
|
||||
*/
|
||||
public function searchPersons($query, array $parameters = array(), array $headers = array())
|
||||
|
@ -84,8 +83,8 @@ class Search
|
|||
* Search for lists by name and description.
|
||||
*
|
||||
* @param $query
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @return mixed
|
||||
*/
|
||||
public function searchList($query, array $parameters = array(), array $headers = array())
|
||||
|
@ -99,8 +98,8 @@ class Search
|
|||
* Search for companies by name.
|
||||
*
|
||||
* @param $query
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @return mixed
|
||||
*/
|
||||
public function searchCompany($query, array $parameters = array(), array $headers = array())
|
||||
|
@ -114,8 +113,8 @@ class Search
|
|||
* Search for companies by name.
|
||||
*
|
||||
* @param $query
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @return mixed
|
||||
*/
|
||||
public function searchKeyword($query, array $parameters = array(), array $headers = array())
|
||||
|
|
31
modules/Tmdb/Api/Timezones.php
Normal file
31
modules/Tmdb/Api/Timezones.php
Normal file
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of the Tmdb PHP API created by Michael Roterman.
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* @package Tmdb
|
||||
* @author Michael Roterman <michael@wtfz.net>
|
||||
* @copyright (c) 2013, Michael Roterman
|
||||
* @version 0.0.1
|
||||
*/
|
||||
namespace Tmdb\Api;
|
||||
|
||||
/**
|
||||
* Class Timezones
|
||||
* @package Tmdb\Api
|
||||
* @see http://docs.themoviedb.apiary.io/#timezones
|
||||
*/
|
||||
class Timezones extends AbstractApi
|
||||
{
|
||||
/**
|
||||
* Get the list of supported timezones for the API methods that support them.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getTimezones()
|
||||
{
|
||||
return $this->get('timezones/list');
|
||||
}
|
||||
}
|
|
@ -17,15 +17,14 @@ namespace Tmdb\Api;
|
|||
* @package Tmdb\Api
|
||||
* @see http://docs.themoviedb.apiary.io/#tv
|
||||
*/
|
||||
class Tv
|
||||
extends AbstractApi
|
||||
class Tv extends AbstractApi
|
||||
{
|
||||
/**
|
||||
* Get the primary information about a TV series by id.
|
||||
*
|
||||
* @param integer $tvshow_id
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @param integer $tvshow_id
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @return mixed
|
||||
*/
|
||||
public function getTvshow($tvshow_id, array $parameters = array(), array $headers = array())
|
||||
|
@ -38,8 +37,8 @@ class Tv
|
|||
* Just like the website, we pull this information from the last season of the series.
|
||||
*
|
||||
* @param $tvshow_id
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @return mixed
|
||||
*/
|
||||
public function getCredits($tvshow_id, array $parameters = array(), array $headers = array())
|
||||
|
@ -51,8 +50,8 @@ class Tv
|
|||
* Get the external ids that we have stored for a TV series.
|
||||
*
|
||||
* @param $tvshow_id
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @return mixed
|
||||
*/
|
||||
public function getExternalIds($tvshow_id, array $parameters = array(), array $headers = array())
|
||||
|
@ -64,8 +63,8 @@ class Tv
|
|||
* Get the images (posters and backdrops) for a TV series.
|
||||
*
|
||||
* @param $tvshow_id
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @return mixed
|
||||
*/
|
||||
public function getImages($tvshow_id, array $parameters = array(), array $headers = array())
|
||||
|
@ -76,8 +75,8 @@ class Tv
|
|||
/**
|
||||
* Get the list of popular TV shows. This list refreshes every day.
|
||||
*
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @return mixed
|
||||
*/
|
||||
public function getPopular(array $parameters = array(), array $headers = array())
|
||||
|
@ -91,8 +90,8 @@ class Tv
|
|||
* By default, this list will only include TV shows that have 2 or more votes.
|
||||
* This list refreshes every day.
|
||||
*
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @return mixed
|
||||
*/
|
||||
public function getTopRated(array $parameters = array(), array $headers = array())
|
||||
|
@ -105,14 +104,54 @@ class Tv
|
|||
*
|
||||
* These translations cascade down to the episode level.
|
||||
*
|
||||
* @param int $tvshow_id
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @param int $tvshow_id
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @return mixed
|
||||
*/
|
||||
public function getTranslations($tvshow_id, array $parameters = array(), array $headers = array())
|
||||
{
|
||||
$this->get('tv/' . $tvshow_id . '/translations', $parameters, $headers);
|
||||
return $this->get('tv/' . $tvshow_id . '/translations', $parameters, $headers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of TV shows that are currently on the air.
|
||||
*
|
||||
* This query looks for any TV show that has an episode with an air date in the next 7 days.
|
||||
*
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @return mixed
|
||||
*/
|
||||
public function getOnTheAir(array $parameters = array(), array $headers = array())
|
||||
{
|
||||
return $this->get('tv/on_the_air', $parameters, $headers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of TV shows that air today.
|
||||
*
|
||||
* Without a specified timezone, this query defaults to EST (Eastern Time UTC-05:00).
|
||||
*
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @return mixed
|
||||
*/
|
||||
public function getAiringToday(array $parameters = array(), array $headers = array())
|
||||
{
|
||||
return $this->get('tv/airing_today', $parameters, $headers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the videos that have been added to a TV series (trailers, opening credits, etc...)
|
||||
*
|
||||
* @param int $tvshow_id
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @return mixed
|
||||
*/
|
||||
public function getVideos($tvshow_id, array $parameters = array(), array $headers = array())
|
||||
{
|
||||
return $this->get('tv/' . $tvshow_id . '/videos', $parameters, $headers);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,8 +17,7 @@ namespace Tmdb\Api;
|
|||
* @package Tmdb\Api
|
||||
* @see http://docs.themoviedb.apiary.io/#tvepisodes
|
||||
*/
|
||||
class TvEpisode
|
||||
extends AbstractApi
|
||||
class TvEpisode extends AbstractApi
|
||||
{
|
||||
/**
|
||||
* Get the primary information about a TV episode by combination of a season and episode number.
|
||||
|
@ -26,13 +25,27 @@ class TvEpisode
|
|||
* @param $tvshow_id
|
||||
* @param $season_number
|
||||
* @param $episode_number
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @return mixed
|
||||
*/
|
||||
public function getEpisode($tvshow_id, $season_number, $episode_number, array $parameters = array(), array $headers = array())
|
||||
{
|
||||
return $this->get(sprintf('tv/%s/season/%s/episode/%s', $tvshow_id, $season_number,$episode_number), $parameters, $headers);
|
||||
public function getEpisode(
|
||||
$tvshow_id,
|
||||
$season_number,
|
||||
$episode_number,
|
||||
array $parameters = array(),
|
||||
array $headers = array()
|
||||
) {
|
||||
return $this->get(
|
||||
sprintf(
|
||||
'tv/%s/season/%s/episode/%s',
|
||||
$tvshow_id,
|
||||
$season_number,
|
||||
$episode_number
|
||||
),
|
||||
$parameters,
|
||||
$headers
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -41,13 +54,27 @@ class TvEpisode
|
|||
* @param $tvshow_id
|
||||
* @param $season_number
|
||||
* @param $episode_number
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @return mixed
|
||||
*/
|
||||
public function getCredits($tvshow_id, $season_number, $episode_number, array $parameters = array(), array $headers = array())
|
||||
{
|
||||
return $this->get(sprintf('tv/%s/season/%s/episode/%s/credits', $tvshow_id, $season_number,$episode_number), $parameters, $headers);
|
||||
public function getCredits(
|
||||
$tvshow_id,
|
||||
$season_number,
|
||||
$episode_number,
|
||||
array $parameters = array(),
|
||||
array $headers = array()
|
||||
) {
|
||||
return $this->get(
|
||||
sprintf(
|
||||
'tv/%s/season/%s/episode/%s/credits',
|
||||
$tvshow_id,
|
||||
$season_number,
|
||||
$episode_number
|
||||
),
|
||||
$parameters,
|
||||
$headers
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -56,13 +83,27 @@ class TvEpisode
|
|||
* @param $tvshow_id
|
||||
* @param $season_number
|
||||
* @param $episode_number
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @return mixed
|
||||
*/
|
||||
public function getExternalIds($tvshow_id, $season_number, $episode_number, array $parameters = array(), array $headers = array())
|
||||
{
|
||||
return $this->get(sprintf('tv/%s/season/%s/episode/%s/external_ids', $tvshow_id, $season_number,$episode_number), $parameters, $headers);
|
||||
public function getExternalIds(
|
||||
$tvshow_id,
|
||||
$season_number,
|
||||
$episode_number,
|
||||
array $parameters = array(),
|
||||
array $headers = array()
|
||||
) {
|
||||
return $this->get(
|
||||
sprintf(
|
||||
'tv/%s/season/%s/episode/%s/external_ids',
|
||||
$tvshow_id,
|
||||
$season_number,
|
||||
$episode_number
|
||||
),
|
||||
$parameters,
|
||||
$headers
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -71,12 +112,55 @@ class TvEpisode
|
|||
* @param $tvshow_id
|
||||
* @param $season_number
|
||||
* @param $episode_number
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @return mixed
|
||||
*/
|
||||
public function getImages($tvshow_id, $season_number, $episode_number, array $parameters = array(), array $headers = array())
|
||||
{
|
||||
return $this->get(sprintf('tv/%s/season/%s/episode/%s/images', $tvshow_id, $season_number,$episode_number), $parameters, $headers);
|
||||
public function getImages(
|
||||
$tvshow_id,
|
||||
$season_number,
|
||||
$episode_number,
|
||||
array $parameters = array(),
|
||||
array $headers = array()
|
||||
) {
|
||||
return $this->get(
|
||||
sprintf(
|
||||
'tv/%s/season/%s/episode/%s/images',
|
||||
$tvshow_id,
|
||||
$season_number,
|
||||
$episode_number
|
||||
),
|
||||
$parameters,
|
||||
$headers
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the videos that have been added to a TV episode (teasers, clips, etc...)
|
||||
*
|
||||
* @param $tvshow_id
|
||||
* @param $season_number
|
||||
* @param $episode_number
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @return mixed
|
||||
*/
|
||||
public function getVideos(
|
||||
$tvshow_id,
|
||||
$season_number,
|
||||
$episode_number,
|
||||
array $parameters = array(),
|
||||
array $headers = array()
|
||||
) {
|
||||
return $this->get(
|
||||
sprintf(
|
||||
'tv/%s/season/%s/episode/%s/videos',
|
||||
$tvshow_id,
|
||||
$season_number,
|
||||
$episode_number
|
||||
),
|
||||
$parameters,
|
||||
$headers
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,16 +17,15 @@ namespace Tmdb\Api;
|
|||
* @package Tmdb\Api
|
||||
* @see http://docs.themoviedb.apiary.io/#tvseasons
|
||||
*/
|
||||
class TvSeason
|
||||
extends AbstractApi
|
||||
class TvSeason extends AbstractApi
|
||||
{
|
||||
/**
|
||||
* Get the primary information about a TV season by its season number.
|
||||
*
|
||||
* @param $tvshow_id
|
||||
* @param $season_number
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @return mixed
|
||||
*/
|
||||
public function getSeason($tvshow_id, $season_number, array $parameters = array(), array $headers = array())
|
||||
|
@ -39,8 +38,8 @@ class TvSeason
|
|||
*
|
||||
* @param $tvshow_id
|
||||
* @param $season_number
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @return mixed
|
||||
*/
|
||||
public function getCredits($tvshow_id, $season_number, array $parameters = array(), array $headers = array())
|
||||
|
@ -53,8 +52,8 @@ class TvSeason
|
|||
*
|
||||
* @param $tvshow_id
|
||||
* @param $season_number
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @return mixed
|
||||
*/
|
||||
public function getExternalIds($tvshow_id, $season_number, array $parameters = array(), array $headers = array())
|
||||
|
@ -67,12 +66,26 @@ class TvSeason
|
|||
*
|
||||
* @param $tvshow_id
|
||||
* @param $season_number
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @return mixed
|
||||
*/
|
||||
public function getImages($tvshow_id, $season_number, array $parameters = array(), array $headers = array())
|
||||
{
|
||||
return $this->get(sprintf('tv/%s/season/%s/images', $tvshow_id, $season_number), $parameters, $headers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the videos that have been added to a TV season (trailers, teasers, etc...)
|
||||
*
|
||||
* @param $tvshow_id
|
||||
* @param $season_number
|
||||
* @param array $parameters
|
||||
* @param array $headers
|
||||
* @return mixed
|
||||
*/
|
||||
public function getVideos($tvshow_id, $season_number, array $parameters = array(), array $headers = array())
|
||||
{
|
||||
return $this->get(sprintf('tv/%s/season/%s/videos', $tvshow_id, $season_number), $parameters, $headers);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,12 +11,14 @@
|
|||
* @version 0.0.1
|
||||
*/
|
||||
namespace Tmdb;
|
||||
use Tmdb\Exception\RuntimeException;
|
||||
|
||||
/**
|
||||
* Class ApiToken
|
||||
* @package Tmdb
|
||||
*/
|
||||
class ApiToken {
|
||||
class ApiToken
|
||||
{
|
||||
private $apiToken = null;
|
||||
|
||||
/**
|
||||
|
@ -30,12 +32,18 @@ class ApiToken {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param null $apiToken
|
||||
* @param string $apiToken
|
||||
* @throws RuntimeException
|
||||
* @return $this
|
||||
*/
|
||||
public function setToken($apiToken)
|
||||
{
|
||||
if (!is_string($apiToken)) {
|
||||
throw new RuntimeException('The Apitoken must be set.');
|
||||
}
|
||||
|
||||
$this->apiToken = $apiToken;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
|
|
@ -12,20 +12,17 @@
|
|||
*/
|
||||
namespace Tmdb;
|
||||
|
||||
use Guzzle\Http\Client as GuzzleClient;
|
||||
use Guzzle\Http\ClientInterface;
|
||||
use Tmdb\HttpClient\HttpClient;
|
||||
use Tmdb\HttpClient\HttpClientInterface;
|
||||
use Tmdb\ApiToken as Token;
|
||||
use Tmdb\HttpClient\Plugin\AcceptJsonHeaderPlugin;
|
||||
use Tmdb\HttpClient\Plugin\ApiTokenPlugin;
|
||||
use Tmdb\HttpClient\Plugin\SessionTokenPlugin;
|
||||
|
||||
/**
|
||||
* Client wrapper for TMDB
|
||||
* @package Tmdb
|
||||
*/
|
||||
class Client {
|
||||
class Client
|
||||
{
|
||||
/**
|
||||
* Base API URI
|
||||
*/
|
||||
|
@ -69,40 +66,105 @@ class Client {
|
|||
*/
|
||||
private $httpClient;
|
||||
|
||||
/**
|
||||
* @var \Psr\Log\LoggerInterface
|
||||
*/
|
||||
private $logger;
|
||||
|
||||
/**
|
||||
* Holds the log path
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $logPath;
|
||||
|
||||
/**
|
||||
* Enable logging?
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
private $logEnabled = false;
|
||||
|
||||
/**
|
||||
* Stores the cache path
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $cachePath;
|
||||
|
||||
/**
|
||||
* Stores wether the cache is enabled or not
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
private $cacheEnabled = false;
|
||||
|
||||
/**
|
||||
* Construct our client
|
||||
*
|
||||
* @param ClientInterface|null $httpClient
|
||||
* @param ApiToken $token
|
||||
* @param boolean $secure
|
||||
* @param ApiToken $token
|
||||
* @param boolean $secure
|
||||
* @param array $options
|
||||
*/
|
||||
public function __construct(Token $token, ClientInterface $httpClient = null, $secure = false)
|
||||
public function __construct(
|
||||
ApiToken $token,
|
||||
ClientInterface $httpClient = null,
|
||||
$secure = false,
|
||||
$options = array()
|
||||
)
|
||||
{
|
||||
$this->setToken($token);
|
||||
$this->setSecure($secure);
|
||||
$this->constructHttpClient(
|
||||
$httpClient,
|
||||
array_merge(
|
||||
array(
|
||||
'token' => $this->getToken(),
|
||||
'secure' => $this->getSecure()
|
||||
),
|
||||
$options
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$httpClient = $httpClient ?: new GuzzleClient($this->getBaseUrl());
|
||||
|
||||
if ($httpClient instanceof \Guzzle\Common\HasDispatcherInterface) {
|
||||
$apiTokenPlugin = new ApiTokenPlugin($token);
|
||||
$httpClient->addSubscriber($apiTokenPlugin);
|
||||
|
||||
$acceptJsonHeaderPlugin = new AcceptJsonHeaderPlugin();
|
||||
$httpClient->addSubscriber($acceptJsonHeaderPlugin);
|
||||
}
|
||||
|
||||
$this->httpClient = new HttpClient($this->getBaseUrl(), array(), $httpClient);
|
||||
/**
|
||||
* Construct the http client
|
||||
*
|
||||
* @param ClientInterface $httpClient
|
||||
* @param array $options
|
||||
* @return void
|
||||
*/
|
||||
private function constructHttpClient(ClientInterface $httpClient = null, array $options)
|
||||
{
|
||||
$httpClient = $httpClient ?: new \Guzzle\Http\Client($this->getBaseUrl());
|
||||
$this->httpClient = new HttpClient(
|
||||
$this->getBaseUrl(),
|
||||
$options,
|
||||
$httpClient
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the token subscriber
|
||||
*
|
||||
* @param Token $token
|
||||
* @return Token
|
||||
*/
|
||||
public function getToken()
|
||||
{
|
||||
return $this->token !== null ? $this->token : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the token subscriber
|
||||
*
|
||||
* @param Token $token
|
||||
* @return $this
|
||||
*/
|
||||
public function setToken(Token $token)
|
||||
{
|
||||
$this->token = $token;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -283,7 +345,23 @@ class Client {
|
|||
}
|
||||
|
||||
/**
|
||||
* @return HttpClientInterface
|
||||
* @return Api\Timezones
|
||||
*/
|
||||
public function getTimezonesApi()
|
||||
{
|
||||
return new Api\Timezones($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Api\GuestSession
|
||||
*/
|
||||
public function getGuestSessionApi()
|
||||
{
|
||||
return new Api\GuestSession($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return HttpClient|HttpClientInterface
|
||||
*/
|
||||
public function getHttpClient()
|
||||
{
|
||||
|
@ -313,12 +391,17 @@ class Client {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param boolean $secure
|
||||
* @param boolean $secure
|
||||
* @return $this
|
||||
*/
|
||||
public function setSecure($secure)
|
||||
{
|
||||
$this->secure = $secure;
|
||||
|
||||
if ($this->httpClient instanceof HttpClientInterface) {
|
||||
$this->getHttpClient()->setBaseUrl($this->getBaseUrl());
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -331,17 +414,17 @@ class Client {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param SessionToken $sessionToken
|
||||
* @param SessionToken $sessionToken
|
||||
* @return $this
|
||||
*/
|
||||
public function setSessionToken($sessionToken)
|
||||
{
|
||||
if ($this->httpClient->getClient() instanceof \Guzzle\Common\HasDispatcherInterface) {
|
||||
$sessionTokenPlugin = new SessionTokenPlugin($sessionToken);
|
||||
$this->httpClient->getClient()->addSubscriber($sessionTokenPlugin);
|
||||
$this->sessionToken = $sessionToken;
|
||||
|
||||
if ($this->httpClient instanceof HttpClientInterface) {
|
||||
$this->getHttpClient()->setSessionToken($sessionToken);
|
||||
}
|
||||
|
||||
$this->sessionToken = $sessionToken;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -352,4 +435,105 @@ class Client {
|
|||
{
|
||||
return $this->sessionToken;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return boolean
|
||||
*/
|
||||
public function getCacheEnabled()
|
||||
{
|
||||
return $this->cacheEnabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set cache path
|
||||
*
|
||||
* Leaving the second argument out will use sys_get_temp_dir()
|
||||
*
|
||||
* @param boolean $enabled
|
||||
* @param string $path
|
||||
* @return $this
|
||||
*/
|
||||
public function setCaching($enabled = true, $path = null)
|
||||
{
|
||||
$this->cacheEnabled = $enabled;
|
||||
$this->cachePath = (null === $path) ?
|
||||
sys_get_temp_dir() . '/php-tmdb-api' :
|
||||
$path
|
||||
;
|
||||
|
||||
$this->getHttpClient()->setCaching(array(
|
||||
'enabled' => $enabled,
|
||||
'cache_path' => $path
|
||||
));
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getCachePath()
|
||||
{
|
||||
return $this->cachePath;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Psr\Log\LoggerInterface $logger
|
||||
* @return $this
|
||||
*/
|
||||
public function setLogger($logger)
|
||||
{
|
||||
$this->logger = $logger;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Psr\Log\LoggerInterface
|
||||
*/
|
||||
public function getLogger()
|
||||
{
|
||||
return $this->logger;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return boolean
|
||||
*/
|
||||
public function getLogEnabled()
|
||||
{
|
||||
return $this->logEnabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set log path
|
||||
*
|
||||
* Leaving the second argument out will use sys_get_temp_dir()
|
||||
*
|
||||
* @param boolean $enabled
|
||||
* @param string $path
|
||||
* @return $this
|
||||
*/
|
||||
public function setLogging($enabled = true, $path = null)
|
||||
{
|
||||
$this->logEnabled = $enabled;
|
||||
$this->logPath = (null === $path) ?
|
||||
sys_get_temp_dir() . '/php-tmdb-api.log' :
|
||||
$path
|
||||
;
|
||||
|
||||
$this->getHttpClient()->setLogging(array(
|
||||
'enabled' => $enabled,
|
||||
'log_path' => $path
|
||||
));
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getLogPath()
|
||||
{
|
||||
return $this->logPath;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,12 +21,13 @@ use Tmdb\Model\AbstractModel;
|
|||
* Class ObjectHydrator
|
||||
* @package Tmdb\Common
|
||||
*/
|
||||
class ObjectHydrator {
|
||||
class ObjectHydrator
|
||||
{
|
||||
/**
|
||||
* Hydrate the object with data
|
||||
*
|
||||
* @param AbstractModel $object
|
||||
* @param array $data
|
||||
* @param AbstractModel $object
|
||||
* @param array $data
|
||||
* @return AbstractModel
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
|
@ -35,7 +36,7 @@ class ObjectHydrator {
|
|||
if (!empty($data)) {
|
||||
foreach ($data as $k => $v) {
|
||||
|
||||
if (in_array($k, $object::$_properties)) {
|
||||
if (in_array($k, $object::$properties)) {
|
||||
|
||||
$method = $this->camelize(
|
||||
sprintf('set_%s', $k)
|
||||
|
@ -47,7 +48,7 @@ class ObjectHydrator {
|
|||
$method,
|
||||
get_class($object)
|
||||
));
|
||||
}else{
|
||||
} else {
|
||||
$object->$method($v);
|
||||
}
|
||||
}
|
||||
|
@ -62,16 +63,21 @@ class ObjectHydrator {
|
|||
*
|
||||
* @see https://gist.github.com/troelskn/751517
|
||||
*
|
||||
* @param string $candidate
|
||||
* @param string $candidate
|
||||
* @return string
|
||||
*/
|
||||
public function camelize($candidate)
|
||||
{
|
||||
return lcfirst(
|
||||
implode('',
|
||||
array_map('ucfirst',
|
||||
array_map('strtolower',
|
||||
explode('_', $candidate
|
||||
implode(
|
||||
'',
|
||||
array_map(
|
||||
'ucfirst',
|
||||
array_map(
|
||||
'strtolower',
|
||||
explode(
|
||||
'_',
|
||||
$candidate
|
||||
)
|
||||
)
|
||||
)
|
||||
|
|
|
@ -16,6 +16,6 @@ namespace Tmdb\Exception;
|
|||
* Class InvalidArgumentException
|
||||
* @package Tmdb\Exception
|
||||
*/
|
||||
class InvalidArgumentException extends \InvalidArgumentException {
|
||||
|
||||
class InvalidArgumentException extends \InvalidArgumentException
|
||||
{
|
||||
}
|
||||
|
|
|
@ -16,6 +16,6 @@ namespace Tmdb\Exception;
|
|||
* Class MissingArgumentException
|
||||
* @package Tmdb\Exception
|
||||
*/
|
||||
class MissingArgumentException extends \InvalidArgumentException {
|
||||
|
||||
class MissingArgumentException extends \InvalidArgumentException
|
||||
{
|
||||
}
|
||||
|
|
21
modules/Tmdb/Exception/MissingSessionTokenException.php
Normal file
21
modules/Tmdb/Exception/MissingSessionTokenException.php
Normal file
|
@ -0,0 +1,21 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of the Tmdb PHP API created by Michael Roterman.
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* @package Tmdb
|
||||
* @author Michael Roterman <michael@wtfz.net>
|
||||
* @copyright (c) 2013, Michael Roterman
|
||||
* @version 0.0.1
|
||||
*/
|
||||
namespace Tmdb\Exception;
|
||||
|
||||
/**
|
||||
* Class MissingSessionTokenException
|
||||
* @package Tmdb\Exception
|
||||
*/
|
||||
class MissingSessionTokenException extends \RuntimeException
|
||||
{
|
||||
}
|
|
@ -16,6 +16,6 @@ namespace Tmdb\Exception;
|
|||
* Class NotImplementedException
|
||||
* @package Tmdb\Exception
|
||||
*/
|
||||
class NotImplementedException extends \Exception {
|
||||
|
||||
class NotImplementedException extends \Exception
|
||||
{
|
||||
}
|
||||
|
|
|
@ -16,6 +16,6 @@ namespace Tmdb\Exception;
|
|||
* Class RuntimeException
|
||||
* @package Tmdb\Exception
|
||||
*/
|
||||
class RuntimeException extends \RuntimeException {
|
||||
|
||||
class RuntimeException extends \RuntimeException
|
||||
{
|
||||
}
|
||||
|
|
26
modules/Tmdb/Exception/TmdbApiException.php
Normal file
26
modules/Tmdb/Exception/TmdbApiException.php
Normal file
|
@ -0,0 +1,26 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of the Tmdb PHP API created by Michael Roterman.
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* @package Tmdb
|
||||
* @author Michael Roterman <michael@wtfz.net>
|
||||
* @copyright (c) 2013, Michael Roterman
|
||||
* @version 0.0.1
|
||||
*/
|
||||
namespace Tmdb\Exception;
|
||||
|
||||
/**
|
||||
* Class TmdbApiException
|
||||
* @package Tmdb\Exception
|
||||
*/
|
||||
class TmdbApiException extends \Exception
|
||||
{
|
||||
public function __construct($message, $code)
|
||||
{
|
||||
$this->message = $message;
|
||||
$this->code = $code;
|
||||
}
|
||||
}
|
|
@ -16,6 +16,6 @@ namespace Tmdb\Exception;
|
|||
* Class UnauthorizedRequestTokenException
|
||||
* @package Tmdb\Exception
|
||||
*/
|
||||
class UnauthorizedRequestTokenException extends \RuntimeException {
|
||||
|
||||
class UnauthorizedRequestTokenException extends \RuntimeException
|
||||
{
|
||||
}
|
||||
|
|
|
@ -21,11 +21,12 @@ use Tmdb\Model\Common\GenericCollection;
|
|||
* Class AbstractFactory
|
||||
* @package Tmdb\Factory
|
||||
*/
|
||||
abstract class AbstractFactory {
|
||||
abstract class AbstractFactory
|
||||
{
|
||||
/**
|
||||
* Convert an array to an hydrated object
|
||||
*
|
||||
* @param array $data
|
||||
* @param array $data
|
||||
* @return AbstractModel
|
||||
*/
|
||||
abstract public function create(array $data = array());
|
||||
|
@ -33,19 +34,19 @@ abstract class AbstractFactory {
|
|||
/**
|
||||
* Convert an array with an collection of items to an hydrated object collection
|
||||
*
|
||||
* @param array $data
|
||||
* @param array $data
|
||||
* @return GenericCollection
|
||||
*/
|
||||
abstract public function createCollection(array $data = array());
|
||||
|
||||
/**
|
||||
* Create a generic collection of data and map it on the class by it's static parameter $_properties
|
||||
* Create a generic collection of data and map it on the class by it's static parameter $properties
|
||||
*
|
||||
* @param array $data
|
||||
* @param array $data
|
||||
* @param $class
|
||||
* @return GenericCollection
|
||||
*/
|
||||
protected function createGenericCollection(array $data = array(), $class)
|
||||
protected function createGenericCollection($data = array(), $class)
|
||||
{
|
||||
if (is_object($class)) {
|
||||
$class = get_class($class);
|
||||
|
@ -53,7 +54,11 @@ abstract class AbstractFactory {
|
|||
|
||||
$collection = new GenericCollection();
|
||||
|
||||
foreach($data as $item) {
|
||||
if (null === $data) {
|
||||
return $collection;
|
||||
}
|
||||
|
||||
foreach ($data as $item) {
|
||||
$collection->add(null, $this->hydrate(new $class(), $item));
|
||||
}
|
||||
|
||||
|
@ -63,14 +68,18 @@ abstract class AbstractFactory {
|
|||
/**
|
||||
* Create a result collection
|
||||
*
|
||||
* @param array $data
|
||||
* @param string $method
|
||||
* @param array $data
|
||||
* @param string $method
|
||||
* @return ResultCollection
|
||||
*/
|
||||
public function createResultCollection(array $data = array(), $method = 'create')
|
||||
public function createResultCollection($data = array(), $method = 'create')
|
||||
{
|
||||
$collection = new ResultCollection();
|
||||
|
||||
if (null === $data) {
|
||||
return $collection;
|
||||
}
|
||||
|
||||
if (array_key_exists('page', $data)) {
|
||||
$collection->setPage($data['page']);
|
||||
}
|
||||
|
@ -87,7 +96,7 @@ abstract class AbstractFactory {
|
|||
$data = $data['results'];
|
||||
}
|
||||
|
||||
foreach($data as $item) {
|
||||
foreach ($data as $item) {
|
||||
$collection->add(null, $this->$method($item));
|
||||
}
|
||||
|
||||
|
@ -97,8 +106,8 @@ abstract class AbstractFactory {
|
|||
/**
|
||||
* Hydrate the object with data
|
||||
*
|
||||
* @param AbstractModel $object
|
||||
* @param array $data
|
||||
* @param AbstractModel $object
|
||||
* @param array $data
|
||||
* @return AbstractModel
|
||||
*/
|
||||
protected function hydrate(AbstractModel $object, $data = array())
|
||||
|
|
|
@ -61,17 +61,18 @@ class AccountFactory extends AbstractFactory
|
|||
/**
|
||||
* Create movie
|
||||
*
|
||||
* @param array $data
|
||||
* @param array $data
|
||||
* @return \Tmdb\Model\Movie
|
||||
*/
|
||||
public function createMovie(array $data = array()) {
|
||||
public function createMovie(array $data = array())
|
||||
{
|
||||
return $this->getMovieFactory()->create($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create list item
|
||||
*
|
||||
* @param array $data
|
||||
* @param array $data
|
||||
* @return \Tmdb\Model\AbstractModel
|
||||
*/
|
||||
public function createListItem(array $data = array())
|
||||
|
@ -94,12 +95,13 @@ class AccountFactory extends AbstractFactory
|
|||
}
|
||||
|
||||
/**
|
||||
* @param \Tmdb\Factory\MovieFactory $movieFactory
|
||||
* @param \Tmdb\Factory\MovieFactory $movieFactory
|
||||
* @return $this
|
||||
*/
|
||||
public function setMovieFactory($movieFactory)
|
||||
{
|
||||
$this->movieFactory = $movieFactory;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -112,12 +114,13 @@ class AccountFactory extends AbstractFactory
|
|||
}
|
||||
|
||||
/**
|
||||
* @param \Tmdb\Factory\ImageFactory $imageFactory
|
||||
* @param \Tmdb\Factory\ImageFactory $imageFactory
|
||||
* @return $this
|
||||
*/
|
||||
public function setImageFactory($imageFactory)
|
||||
{
|
||||
$this->imageFactory = $imageFactory;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
namespace Tmdb\Factory;
|
||||
|
||||
use Tmdb\Exception\NotImplementedException;
|
||||
use Tmdb\GuestSessionToken;
|
||||
use Tmdb\RequestToken;
|
||||
use Tmdb\SessionToken;
|
||||
|
||||
|
@ -47,7 +48,7 @@ class AuthenticationFactory extends AbstractFactory
|
|||
/**
|
||||
* Create request token
|
||||
*
|
||||
* @param array $data
|
||||
* @param array $data
|
||||
* @return RequestToken
|
||||
*/
|
||||
public function createRequestToken(array $data = array())
|
||||
|
@ -72,7 +73,7 @@ class AuthenticationFactory extends AbstractFactory
|
|||
/**
|
||||
* Create session token for user
|
||||
*
|
||||
* @param array $data
|
||||
* @param array $data
|
||||
* @return SessionToken
|
||||
*/
|
||||
public function createSessionToken(array $data = array())
|
||||
|
@ -93,12 +94,12 @@ class AuthenticationFactory extends AbstractFactory
|
|||
/**
|
||||
* Create session token for guest
|
||||
*
|
||||
* @param array $data
|
||||
* @param array $data
|
||||
* @return SessionToken
|
||||
*/
|
||||
public function createGuestSessionToken(array $data = array())
|
||||
{
|
||||
$token = new SessionToken();
|
||||
$token = new GuestSessionToken();
|
||||
|
||||
if (array_key_exists('expires_at', $data)) {
|
||||
$token->setExpiresAt(new \DateTime($data['expires_at']));
|
||||
|
|
|
@ -42,11 +42,11 @@ class CertificationFactory extends AbstractFactory
|
|||
|
||||
$collection = new GenericCollection();
|
||||
|
||||
foreach($data as $country => $certifications) {
|
||||
foreach ($data as $country => $certifications) {
|
||||
$certification = new Certification();
|
||||
$certification->setCountry($country);
|
||||
|
||||
foreach($certifications as $countryCertification) {
|
||||
foreach ($certifications as $countryCertification) {
|
||||
$object = $this->create($countryCertification);
|
||||
|
||||
$certification->getCertifications()->add(null, $object);
|
||||
|
|
|
@ -53,7 +53,7 @@ class ChangesFactory extends AbstractFactory
|
|||
$data = $data['results'];
|
||||
}
|
||||
|
||||
foreach($data as $item) {
|
||||
foreach ($data as $item) {
|
||||
$collection->add(null, $this->create($item));
|
||||
}
|
||||
|
||||
|
|
|
@ -55,15 +55,21 @@ class CollectionFactory extends AbstractFactory
|
|||
}
|
||||
|
||||
if (array_key_exists('backdrop_path', $data)) {
|
||||
$collection->setBackdropImage($this->getImageFactory()->createFromPath($data['backdrop_path'], 'backdrop_path'));
|
||||
$collection->setBackdropImage(
|
||||
$this->getImageFactory()->createFromPath($data['backdrop_path'], 'backdrop_path')
|
||||
);
|
||||
}
|
||||
|
||||
if (array_key_exists('images', $data)) {
|
||||
$collection->setImages($this->getImageFactory()->createCollectionFromMovie($data['images']));
|
||||
$collection->setImages(
|
||||
$this->getImageFactory()->createCollectionFromMovie($data['images'])
|
||||
);
|
||||
}
|
||||
|
||||
if (array_key_exists('poster_path', $data)) {
|
||||
$collection->setPosterImage($this->getImageFactory()->createFromPath($data['poster_path'], 'poster_path'));
|
||||
$collection->setPosterImage(
|
||||
$this->getImageFactory()->createFromPath($data['poster_path'], 'poster_path')
|
||||
);
|
||||
}
|
||||
|
||||
return $this->hydrate($collection, $data);
|
||||
|
@ -76,7 +82,7 @@ class CollectionFactory extends AbstractFactory
|
|||
{
|
||||
$collection = new GenericCollection();
|
||||
|
||||
foreach($data as $item) {
|
||||
foreach ($data as $item) {
|
||||
$collection->add(null, $this->create($item));
|
||||
}
|
||||
|
||||
|
@ -84,12 +90,13 @@ class CollectionFactory extends AbstractFactory
|
|||
}
|
||||
|
||||
/**
|
||||
* @param \Tmdb\Factory\ImageFactory $imageFactory
|
||||
* @param \Tmdb\Factory\ImageFactory $imageFactory
|
||||
* @return $this
|
||||
*/
|
||||
public function setImageFactory($imageFactory)
|
||||
{
|
||||
$this->imageFactory = $imageFactory;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -102,12 +109,13 @@ class CollectionFactory extends AbstractFactory
|
|||
}
|
||||
|
||||
/**
|
||||
* @param \Tmdb\Factory\MovieFactory $movieFactory
|
||||
* @param \Tmdb\Factory\MovieFactory $movieFactory
|
||||
* @return $this
|
||||
*/
|
||||
public function setMovieFactory($movieFactory)
|
||||
{
|
||||
$this->movieFactory = $movieFactory;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ class ChangeFactory extends AbstractFactory
|
|||
if (array_key_exists('items', $data)) {
|
||||
$items = new GenericCollection();
|
||||
|
||||
foreach($data['items'] as $item) {
|
||||
foreach ($data['items'] as $item) {
|
||||
$item = $this->createChangeItem($item);
|
||||
|
||||
$items->add(null, $item);
|
||||
|
@ -47,7 +47,7 @@ class ChangeFactory extends AbstractFactory
|
|||
/**
|
||||
* Create individual change items
|
||||
*
|
||||
* @param array $data
|
||||
* @param array $data
|
||||
* @return \Tmdb\Model\AbstractModel
|
||||
*/
|
||||
private function createChangeItem(array $data = array())
|
||||
|
@ -66,7 +66,7 @@ class ChangeFactory extends AbstractFactory
|
|||
$data = $data['changes'];
|
||||
}
|
||||
|
||||
foreach($data as $item) {
|
||||
foreach ($data as $item) {
|
||||
$collection->add(null, $this->create($item));
|
||||
}
|
||||
|
||||
|
|
|
@ -21,23 +21,24 @@ use Tmdb\Model\Common\GenericCollection;
|
|||
* Class GenericCollectionFactory
|
||||
* @package Tmdb\Factory\Common
|
||||
*/
|
||||
class GenericCollectionFactory {
|
||||
class GenericCollectionFactory
|
||||
{
|
||||
/**
|
||||
* @param array $data
|
||||
* @param array $data
|
||||
* @param $class
|
||||
* @return GenericCollection
|
||||
*/
|
||||
public function create(array $data = array(), $class)
|
||||
public function create(array $data, $class)
|
||||
{
|
||||
return $this->createCollection($data, $class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $data
|
||||
* @param array $data
|
||||
* @param $class
|
||||
* @return GenericCollection
|
||||
*/
|
||||
public function createCollection(array $data = array(), $class)
|
||||
public function createCollection(array $data, $class)
|
||||
{
|
||||
if (is_object($class)) {
|
||||
$class = get_class($class);
|
||||
|
@ -46,7 +47,7 @@ class GenericCollectionFactory {
|
|||
$collection = new GenericCollection();
|
||||
$objectHydrator = new ObjectHydrator();
|
||||
|
||||
foreach($data as $item) {
|
||||
foreach ($data as $item) {
|
||||
$collection->add(null, $objectHydrator->hydrate(new $class(), $item));
|
||||
}
|
||||
|
||||
|
|
72
modules/Tmdb/Factory/Common/VideoFactory.php
Normal file
72
modules/Tmdb/Factory/Common/VideoFactory.php
Normal file
|
@ -0,0 +1,72 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of the Tmdb PHP API created by Michael Roterman.
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* @package Tmdb
|
||||
* @author Michael Roterman <michael@wtfz.net>
|
||||
* @copyright (c) 2013, Michael Roterman
|
||||
* @version 0.0.1
|
||||
*/
|
||||
namespace Tmdb\Factory\Common;
|
||||
|
||||
use Tmdb\Factory\AbstractFactory;
|
||||
use Tmdb\Model\Collection\Videos;
|
||||
use Tmdb\Model\Common\Video;
|
||||
|
||||
/**
|
||||
* Class VideoFactory
|
||||
* @package Tmdb\Factory\Common
|
||||
*/
|
||||
class VideoFactory extends AbstractFactory
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function create(array $data = array())
|
||||
{
|
||||
$videoType = $this->resolveVideoType($data);
|
||||
|
||||
return $this->hydrate($videoType, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function createCollection(array $data = array())
|
||||
{
|
||||
$collection = new Videos();
|
||||
|
||||
if (array_key_exists('videos', $data)) {
|
||||
$data = $data['videos'];
|
||||
}
|
||||
|
||||
if (array_key_exists('results', $data)) {
|
||||
$data = $data['results'];
|
||||
}
|
||||
|
||||
foreach ($data as $item) {
|
||||
$collection->add(null, $this->create($item));
|
||||
}
|
||||
|
||||
return $collection;
|
||||
}
|
||||
|
||||
private function resolveVideoType($data)
|
||||
{
|
||||
if (array_key_exists('site', $data) && !empty($data['site'])) {
|
||||
$site = strtolower($data['site']);
|
||||
|
||||
switch ($site) {
|
||||
case 'youtube':
|
||||
return new Video\Youtube();
|
||||
break;
|
||||
default:
|
||||
return new Video();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -56,12 +56,13 @@ class CompanyFactory extends AbstractFactory
|
|||
}
|
||||
|
||||
/**
|
||||
* @param \Tmdb\Factory\ImageFactory $imageFactory
|
||||
* @param \Tmdb\Factory\ImageFactory $imageFactory
|
||||
* @return $this
|
||||
*/
|
||||
public function setImageFactory($imageFactory)
|
||||
{
|
||||
$this->imageFactory = $imageFactory;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
|
|
@ -14,7 +14,6 @@ namespace Tmdb\Factory;
|
|||
|
||||
use Tmdb\Exception\NotImplementedException;
|
||||
use Tmdb\Model\Genre;
|
||||
use Tmdb\Model\Movie;
|
||||
use Tmdb\Model\Credits as Credits;
|
||||
|
||||
/**
|
||||
|
@ -85,16 +84,20 @@ class CreditsFactory extends AbstractFactory
|
|||
*/
|
||||
public function createCollection(array $data = array())
|
||||
{
|
||||
throw new NotImplementedException('Credits are usually obtained through the PeopleFactory, however we might add a shortcut for that here.');
|
||||
throw new NotImplementedException(
|
||||
'Credits are usually obtained through the PeopleFactory,
|
||||
however we might add a shortcut for that here.'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Tmdb\Factory\TvEpisodeFactory $tvEpisodeFactory
|
||||
* @param \Tmdb\Factory\TvEpisodeFactory $tvEpisodeFactory
|
||||
* @return $this
|
||||
*/
|
||||
public function setTvEpisodeFactory($tvEpisodeFactory)
|
||||
{
|
||||
$this->tvEpisodeFactory = $tvEpisodeFactory;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -107,12 +110,13 @@ class CreditsFactory extends AbstractFactory
|
|||
}
|
||||
|
||||
/**
|
||||
* @param \Tmdb\Factory\TvSeasonFactory $tvSeasonFactory
|
||||
* @param \Tmdb\Factory\TvSeasonFactory $tvSeasonFactory
|
||||
* @return $this
|
||||
*/
|
||||
public function setTvSeasonFactory($tvSeasonFactory)
|
||||
{
|
||||
$this->tvSeasonFactory = $tvSeasonFactory;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -125,12 +129,13 @@ class CreditsFactory extends AbstractFactory
|
|||
}
|
||||
|
||||
/**
|
||||
* @param \Tmdb\Factory\PeopleFactory $peopleFactory
|
||||
* @param \Tmdb\Factory\PeopleFactory $peopleFactory
|
||||
* @return $this
|
||||
*/
|
||||
public function setPeopleFactory($peopleFactory)
|
||||
{
|
||||
$this->peopleFactory = $peopleFactory;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
|
|
@ -77,12 +77,13 @@ class FindFactory extends AbstractFactory
|
|||
}
|
||||
|
||||
/**
|
||||
* @param \Tmdb\Factory\MovieFactory $movieFactory
|
||||
* @param \Tmdb\Factory\MovieFactory $movieFactory
|
||||
* @return $this
|
||||
*/
|
||||
public function setMovieFactory($movieFactory)
|
||||
{
|
||||
$this->movieFactory = $movieFactory;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -95,12 +96,13 @@ class FindFactory extends AbstractFactory
|
|||
}
|
||||
|
||||
/**
|
||||
* @param \Tmdb\Factory\PeopleFactory $peopleFactory
|
||||
* @param \Tmdb\Factory\PeopleFactory $peopleFactory
|
||||
* @return $this
|
||||
*/
|
||||
public function setPeopleFactory($peopleFactory)
|
||||
{
|
||||
$this->peopleFactory = $peopleFactory;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -113,12 +115,13 @@ class FindFactory extends AbstractFactory
|
|||
}
|
||||
|
||||
/**
|
||||
* @param \Tmdb\Factory\TvFactory $tvFactory
|
||||
* @param \Tmdb\Factory\TvFactory $tvFactory
|
||||
* @return $this
|
||||
*/
|
||||
public function setTvFactory($tvFactory)
|
||||
{
|
||||
$this->tvFactory = $tvFactory;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -129,6 +132,4 @@ class FindFactory extends AbstractFactory
|
|||
{
|
||||
return $this->tvFactory;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -14,7 +14,6 @@ namespace Tmdb\Factory;
|
|||
|
||||
use Tmdb\Model\Collection\Genres;
|
||||
use Tmdb\Model\Genre;
|
||||
use Tmdb\Model\Movie;
|
||||
|
||||
/**
|
||||
* Class GenreFactory
|
||||
|
@ -43,7 +42,7 @@ class GenreFactory extends AbstractFactory
|
|||
$data = $data['genres'];
|
||||
}
|
||||
|
||||
foreach($data as $item) {
|
||||
foreach ($data as $item) {
|
||||
$collection->addGenre($this->create($item));
|
||||
}
|
||||
|
||||
|
|
36
modules/Tmdb/Factory/GuestSessionFactory.php
Normal file
36
modules/Tmdb/Factory/GuestSessionFactory.php
Normal file
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of the Tmdb PHP API created by Michael Roterman.
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* @package Tmdb
|
||||
* @author Michael Roterman <michael@wtfz.net>
|
||||
* @copyright (c) 2013, Michael Roterman
|
||||
* @version 0.0.1
|
||||
*/
|
||||
namespace Tmdb\Factory;
|
||||
|
||||
/**
|
||||
* Currently a place-holder for future expansions
|
||||
*
|
||||
* Class GuestSessionFactory
|
||||
* @package Tmdb\Factory
|
||||
*/
|
||||
class GuestSessionFactory extends AbstractFactory
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function create(array $data = array())
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function createCollection(array $data = array())
|
||||
{
|
||||
}
|
||||
}
|
|
@ -24,8 +24,8 @@ class ImageFactory extends AbstractFactory
|
|||
/**
|
||||
* Convert an array to an hydrated object
|
||||
*
|
||||
* @param array $data
|
||||
* @param string|null $key
|
||||
* @param array $data
|
||||
* @param string|null $key
|
||||
* @return Image
|
||||
*/
|
||||
public function create(array $data = array(), $key = null)
|
||||
|
@ -41,7 +41,7 @@ class ImageFactory extends AbstractFactory
|
|||
* '/xkQ5yWnMjpC2bGmu7GsD66AAoKO.jpg', 'backdrop_path'
|
||||
*
|
||||
* @param $path
|
||||
* @param string $key
|
||||
* @param string $key
|
||||
* @return Image|Image\BackdropImage|Image\LogoImage|Image\PosterImage|Image\ProfileImage|Image\StillImage
|
||||
*/
|
||||
public function createFromPath($path, $key)
|
||||
|
@ -55,12 +55,12 @@ class ImageFactory extends AbstractFactory
|
|||
/**
|
||||
* Helper function to obtain a new object for an image type
|
||||
*
|
||||
* @param string|null $key
|
||||
* @param string|null $key
|
||||
* @return Image|Image\BackdropImage|Image\LogoImage|Image\PosterImage|Image\ProfileImage|Image\StillImage
|
||||
*/
|
||||
public function resolveImageType($key = null)
|
||||
{
|
||||
switch($key) {
|
||||
switch ($key) {
|
||||
case 'poster':
|
||||
case 'posters':
|
||||
case 'poster_path':
|
||||
|
@ -103,14 +103,14 @@ class ImageFactory extends AbstractFactory
|
|||
/**
|
||||
* Create generic collection
|
||||
*
|
||||
* @param array $data
|
||||
* @param array $data
|
||||
* @return Images
|
||||
*/
|
||||
public function createCollection(array $data = array())
|
||||
{
|
||||
$collection = new Images();
|
||||
|
||||
foreach($data as $item) {
|
||||
foreach ($data as $item) {
|
||||
$collection->add(null, $this->create($item));
|
||||
}
|
||||
|
||||
|
@ -120,21 +120,21 @@ class ImageFactory extends AbstractFactory
|
|||
/**
|
||||
* Create full collection
|
||||
*
|
||||
* @param array $data
|
||||
* @param array $data
|
||||
* @return Images
|
||||
*/
|
||||
public function createImageCollection(array $data = array())
|
||||
{
|
||||
$collection = new Images();
|
||||
|
||||
foreach($data as $format => $formatCollection) {
|
||||
foreach ($data as $format => $formatCollection) {
|
||||
|
||||
if (!is_array($formatCollection)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach($formatCollection as $item) {
|
||||
if (array_key_exists($format, Image::$_formats)) {
|
||||
foreach ($formatCollection as $item) {
|
||||
if (array_key_exists($format, Image::$formats)) {
|
||||
$item = $this->create($item, $format);
|
||||
|
||||
$collection->addImage($item);
|
||||
|
@ -148,7 +148,7 @@ class ImageFactory extends AbstractFactory
|
|||
/**
|
||||
* Create full movie collection
|
||||
*
|
||||
* @param array $data
|
||||
* @param array $data
|
||||
* @return Images
|
||||
*/
|
||||
public function createCollectionFromMovie(array $data = array())
|
||||
|
@ -159,7 +159,7 @@ class ImageFactory extends AbstractFactory
|
|||
/**
|
||||
* Create full tv show collection
|
||||
*
|
||||
* @param array $data
|
||||
* @param array $data
|
||||
* @return Images
|
||||
*/
|
||||
public function createCollectionFromTv(array $data = array())
|
||||
|
@ -170,7 +170,7 @@ class ImageFactory extends AbstractFactory
|
|||
/**
|
||||
* Create full tv season collection
|
||||
*
|
||||
* @param array $data
|
||||
* @param array $data
|
||||
* @return Images
|
||||
*/
|
||||
public function createCollectionFromTvSeason(array $data = array())
|
||||
|
@ -181,7 +181,7 @@ class ImageFactory extends AbstractFactory
|
|||
/**
|
||||
* Create full tv episode collection
|
||||
*
|
||||
* @param array $data
|
||||
* @param array $data
|
||||
* @return Images
|
||||
*/
|
||||
public function createCollectionFromTvEpisode(array $data = array())
|
||||
|
@ -192,7 +192,7 @@ class ImageFactory extends AbstractFactory
|
|||
/**
|
||||
* Create full people collection
|
||||
*
|
||||
* @param array $data
|
||||
* @param array $data
|
||||
* @return Images
|
||||
*/
|
||||
public function createCollectionFromPeople(array $data = array())
|
||||
|
|
|
@ -40,7 +40,7 @@ class JobsFactory extends AbstractFactory
|
|||
$data = $data['jobs'];
|
||||
}
|
||||
|
||||
foreach($data as $item) {
|
||||
foreach ($data as $item) {
|
||||
$collection->add(null, $this->create($item));
|
||||
}
|
||||
|
||||
|
|
|
@ -14,7 +14,6 @@ namespace Tmdb\Factory;
|
|||
|
||||
use Tmdb\Model\Collection\Keywords;
|
||||
use Tmdb\Model\Keyword;
|
||||
use Tmdb\Model\Movie;
|
||||
|
||||
/**
|
||||
* Class KeywordFactory
|
||||
|
@ -43,7 +42,7 @@ class KeywordFactory extends AbstractFactory
|
|||
$data = $data['keywords'];
|
||||
}
|
||||
|
||||
foreach($data as $item) {
|
||||
foreach ($data as $item) {
|
||||
$collection->addKeyword($this->create($item));
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,6 @@ use Tmdb\Factory\Lists\ListItemFactory;
|
|||
use Tmdb\Model\Common\GenericCollection;
|
||||
use Tmdb\Model\Genre;
|
||||
use Tmdb\Model\Lists;
|
||||
use Tmdb\Model\Movie;
|
||||
|
||||
/**
|
||||
* Class ListFactory
|
||||
|
@ -100,7 +99,7 @@ class ListFactory extends AbstractFactory
|
|||
{
|
||||
$collection = new GenericCollection();
|
||||
|
||||
foreach($data as $item) {
|
||||
foreach ($data as $item) {
|
||||
$collection->add(null, $this->create($item));
|
||||
}
|
||||
|
||||
|
@ -108,12 +107,13 @@ class ListFactory extends AbstractFactory
|
|||
}
|
||||
|
||||
/**
|
||||
* @param \Tmdb\Factory\ImageFactory $imageFactory
|
||||
* @param \Tmdb\Factory\ImageFactory $imageFactory
|
||||
* @return $this
|
||||
*/
|
||||
public function setImageFactory($imageFactory)
|
||||
{
|
||||
$this->imageFactory = $imageFactory;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -126,12 +126,13 @@ class ListFactory extends AbstractFactory
|
|||
}
|
||||
|
||||
/**
|
||||
* @param \Tmdb\Factory\Lists\ListItemFactory $listItemFactory
|
||||
* @param \Tmdb\Factory\Lists\ListItemFactory $listItemFactory
|
||||
* @return $this
|
||||
*/
|
||||
public function setListItemFactory($listItemFactory)
|
||||
{
|
||||
$this->listItemFactory = $listItemFactory;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
|
|
@ -44,11 +44,15 @@ class ListItemFactory extends AbstractFactory
|
|||
|
||||
/** Images */
|
||||
if (array_key_exists('backdrop_path', $data)) {
|
||||
$listItem->setBackdropImage($this->getImageFactory()->createFromPath($data['backdrop_path'], 'backdrop_path'));
|
||||
$listItem->setBackdropImage(
|
||||
$this->getImageFactory()->createFromPath($data['backdrop_path'], 'backdrop_path')
|
||||
);
|
||||
}
|
||||
|
||||
if (array_key_exists('poster_path', $data)) {
|
||||
$listItem->setPosterImage($this->getImageFactory()->createFromPath($data['poster_path'], 'poster_path'));
|
||||
$listItem->setPosterImage(
|
||||
$this->getImageFactory()->createFromPath($data['poster_path'], 'poster_path')
|
||||
);
|
||||
}
|
||||
|
||||
return $this->hydrate($listItem, $data);
|
||||
|
@ -65,7 +69,7 @@ class ListItemFactory extends AbstractFactory
|
|||
$data = $data['items'];
|
||||
}
|
||||
|
||||
foreach($data as $item) {
|
||||
foreach ($data as $item) {
|
||||
$collection->add(null, $this->create($item));
|
||||
}
|
||||
|
||||
|
@ -73,12 +77,13 @@ class ListItemFactory extends AbstractFactory
|
|||
}
|
||||
|
||||
/**
|
||||
* @param \Tmdb\Factory\ImageFactory $imageFactory
|
||||
* @param \Tmdb\Factory\ImageFactory $imageFactory
|
||||
* @return $this
|
||||
*/
|
||||
public function setImageFactory($imageFactory)
|
||||
{
|
||||
$this->imageFactory = $imageFactory;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ class AlternativeTitleFactory extends AbstractFactory
|
|||
{
|
||||
$collection = new GenericCollection();
|
||||
|
||||
foreach($data as $item) {
|
||||
foreach ($data as $item) {
|
||||
$collection->add(null, $this->create($item));
|
||||
}
|
||||
|
||||
|
|
|
@ -52,12 +52,13 @@ class ListItemFactory extends AbstractFactory
|
|||
}
|
||||
|
||||
/**
|
||||
* @param \Tmdb\Factory\ImageFactory $imageFactory
|
||||
* @param \Tmdb\Factory\ImageFactory $imageFactory
|
||||
* @return $this
|
||||
*/
|
||||
public function setImageFactory($imageFactory)
|
||||
{
|
||||
$this->imageFactory = $imageFactory;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
|
|
@ -13,12 +13,15 @@
|
|||
namespace Tmdb\Factory;
|
||||
|
||||
use Tmdb\Factory\Common\ChangeFactory;
|
||||
use Tmdb\Factory\Common\VideoFactory;
|
||||
use Tmdb\Factory\Movie\ListItemFactory;
|
||||
use Tmdb\Factory\People\CastFactory;
|
||||
use Tmdb\Factory\People\CrewFactory;
|
||||
use Tmdb\Model\Common\Country;
|
||||
use Tmdb\Model\Common\GenericCollection;
|
||||
use Tmdb\Model\Common\Trailer\Youtube;
|
||||
use Tmdb\Model\Common\Translation;
|
||||
use Tmdb\Model\Company;
|
||||
use Tmdb\Model\Lists\Result;
|
||||
use Tmdb\Model\Movie;
|
||||
|
||||
|
@ -26,7 +29,8 @@ use Tmdb\Model\Movie;
|
|||
* Class MovieFactory
|
||||
* @package Tmdb\Factory
|
||||
*/
|
||||
class MovieFactory extends AbstractFactory {
|
||||
class MovieFactory extends AbstractFactory
|
||||
{
|
||||
/**
|
||||
* @var People\CastFactory
|
||||
*/
|
||||
|
@ -67,6 +71,11 @@ class MovieFactory extends AbstractFactory {
|
|||
*/
|
||||
private $keywordFactory;
|
||||
|
||||
/**
|
||||
* @var Common\VideoFactory
|
||||
*/
|
||||
private $videoFactory;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
|
@ -80,10 +89,11 @@ class MovieFactory extends AbstractFactory {
|
|||
$this->reviewFactory = new ReviewFactory();
|
||||
$this->listItemFactory = new ListItemFactory();
|
||||
$this->keywordFactory = new KeywordFactory();
|
||||
$this->videoFactory = new VideoFactory();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $data
|
||||
* @param array $data
|
||||
* @return Movie
|
||||
*/
|
||||
public function create(array $data = array())
|
||||
|
@ -138,14 +148,24 @@ class MovieFactory extends AbstractFactory {
|
|||
}
|
||||
|
||||
/**
|
||||
* @TODO actually implement more providers? ( Can't seem to find any quicktime related trailers anyways? ). For now KISS
|
||||
* @TODO actually implement more providers?
|
||||
* ( Can't seem to find any quicktime related trailers anyways? ). For now KISS
|
||||
*/
|
||||
if (array_key_exists('trailers', $data) && array_key_exists('youtube', $data['trailers'])) {
|
||||
$movie->setTrailers($this->createGenericCollection($data['trailers']['youtube'], new Youtube()));
|
||||
}
|
||||
|
||||
if (array_key_exists('videos', $data)) {
|
||||
$movie->setVideos($this->getVideoFactory()->createCollection($data['videos']));
|
||||
}
|
||||
|
||||
if (array_key_exists('translations', $data) && array_key_exists('translations', $data['translations'])) {
|
||||
$movie->setTranslations($this->createGenericCollection($data['translations']['translations'], new Translation()));
|
||||
$movie->setTranslations(
|
||||
$this->createGenericCollection(
|
||||
$data['translations']['translations'],
|
||||
new Translation()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if (array_key_exists('similar_movies', $data)) {
|
||||
|
@ -164,6 +184,18 @@ class MovieFactory extends AbstractFactory {
|
|||
$movie->setChanges($this->getChangeFactory()->createCollection($data['changes']));
|
||||
}
|
||||
|
||||
if (array_key_exists('production_companies', $data)) {
|
||||
$movie->setProductionCompanies(
|
||||
$this->createGenericCollection($data['production_companies'], new Company())
|
||||
);
|
||||
}
|
||||
|
||||
if (array_key_exists('production_countries', $data)) {
|
||||
$movie->setProductionCountries(
|
||||
$this->createGenericCollection($data['production_countries'], new Country())
|
||||
);
|
||||
}
|
||||
|
||||
return $this->hydrate($movie, $data);
|
||||
}
|
||||
|
||||
|
@ -178,7 +210,7 @@ class MovieFactory extends AbstractFactory {
|
|||
$data = $data['results'];
|
||||
}
|
||||
|
||||
foreach($data as $item) {
|
||||
foreach ($data as $item) {
|
||||
$collection->add(null, $this->create($item));
|
||||
}
|
||||
|
||||
|
@ -188,27 +220,29 @@ class MovieFactory extends AbstractFactory {
|
|||
/**
|
||||
* Create result
|
||||
*
|
||||
* @param array $data
|
||||
* @param array $data
|
||||
* @return \Tmdb\Model\AbstractModel
|
||||
*/
|
||||
public function createResult(array $data = array()) {
|
||||
public function createResult(array $data = array())
|
||||
{
|
||||
return $this->hydrate(new Result(), $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create rating
|
||||
*
|
||||
* @param array $data
|
||||
* @param array $data
|
||||
* @return \Tmdb\Model\AbstractModel
|
||||
*/
|
||||
public function createRating(array $data = array()) {
|
||||
public function createRating(array $data = array())
|
||||
{
|
||||
return $this->hydrate(new Movie\Rating(), $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the account states
|
||||
*
|
||||
* @param array $data
|
||||
* @param array $data
|
||||
* @return \Tmdb\Model\AbstractModel
|
||||
*/
|
||||
public function createAccountStates(array $data = array())
|
||||
|
@ -225,12 +259,13 @@ class MovieFactory extends AbstractFactory {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param \Tmdb\Factory\People\CastFactory $castFactory
|
||||
* @param \Tmdb\Factory\People\CastFactory $castFactory
|
||||
* @return $this
|
||||
*/
|
||||
public function setCastFactory($castFactory)
|
||||
{
|
||||
$this->castFactory = $castFactory;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -243,12 +278,13 @@ class MovieFactory extends AbstractFactory {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param \Tmdb\Factory\People\CrewFactory $crewFactory
|
||||
* @param \Tmdb\Factory\People\CrewFactory $crewFactory
|
||||
* @return $this
|
||||
*/
|
||||
public function setCrewFactory($crewFactory)
|
||||
{
|
||||
$this->crewFactory = $crewFactory;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -261,12 +297,13 @@ class MovieFactory extends AbstractFactory {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param \Tmdb\Factory\GenreFactory $genreFactory
|
||||
* @param \Tmdb\Factory\GenreFactory $genreFactory
|
||||
* @return $this
|
||||
*/
|
||||
public function setGenreFactory($genreFactory)
|
||||
{
|
||||
$this->genreFactory = $genreFactory;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -279,12 +316,13 @@ class MovieFactory extends AbstractFactory {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param \Tmdb\Factory\ImageFactory $imageFactory
|
||||
* @param \Tmdb\Factory\ImageFactory $imageFactory
|
||||
* @return $this
|
||||
*/
|
||||
public function setImageFactory($imageFactory)
|
||||
{
|
||||
$this->imageFactory = $imageFactory;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -297,12 +335,13 @@ class MovieFactory extends AbstractFactory {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param \Tmdb\Factory\Common\ChangeFactory $changeFactory
|
||||
* @param \Tmdb\Factory\Common\ChangeFactory $changeFactory
|
||||
* @return $this
|
||||
*/
|
||||
public function setChangeFactory($changeFactory)
|
||||
{
|
||||
$this->changeFactory = $changeFactory;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -315,12 +354,13 @@ class MovieFactory extends AbstractFactory {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param \Tmdb\Factory\ReviewFactory $reviewFactory
|
||||
* @param \Tmdb\Factory\ReviewFactory $reviewFactory
|
||||
* @return $this
|
||||
*/
|
||||
public function setReviewFactory($reviewFactory)
|
||||
{
|
||||
$this->reviewFactory = $reviewFactory;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -333,12 +373,13 @@ class MovieFactory extends AbstractFactory {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param \Tmdb\Factory\Movie\ListItemFactory $listItemFactory
|
||||
* @param \Tmdb\Factory\Movie\ListItemFactory $listItemFactory
|
||||
* @return $this
|
||||
*/
|
||||
public function setListItemFactory($listItemFactory)
|
||||
{
|
||||
$this->listItemFactory = $listItemFactory;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -351,12 +392,13 @@ class MovieFactory extends AbstractFactory {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param \Tmdb\Factory\KeywordFactory $keywordFactory
|
||||
* @param \Tmdb\Factory\KeywordFactory $keywordFactory
|
||||
* @return $this
|
||||
*/
|
||||
public function setKeywordFactory($keywordFactory)
|
||||
{
|
||||
$this->keywordFactory = $keywordFactory;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -367,4 +409,23 @@ class MovieFactory extends AbstractFactory {
|
|||
{
|
||||
return $this->keywordFactory;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Tmdb\Factory\Common\VideoFactory $videoFactory
|
||||
* @return $this
|
||||
*/
|
||||
public function setVideoFactory($videoFactory)
|
||||
{
|
||||
$this->videoFactory = $videoFactory;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Tmdb\Factory\Common\VideoFactory
|
||||
*/
|
||||
public function getVideoFactory()
|
||||
{
|
||||
return $this->videoFactory;
|
||||
}
|
||||
}
|
|
@ -14,7 +14,6 @@ namespace Tmdb\Factory;
|
|||
|
||||
use Tmdb\Model\Common\GenericCollection;
|
||||
use Tmdb\Model\Network;
|
||||
use Tmdb\Model\Movie;
|
||||
|
||||
/**
|
||||
* Class NetworkFactory
|
||||
|
@ -43,7 +42,7 @@ class NetworkFactory extends AbstractFactory
|
|||
$data = $data['networks'];
|
||||
}
|
||||
|
||||
foreach($data as $item) {
|
||||
foreach ($data as $item) {
|
||||
$collection->add(null, $this->create($item));
|
||||
}
|
||||
|
||||
|
|
|
@ -39,12 +39,11 @@ class CastFactory extends PeopleFactory
|
|||
|
||||
if (is_object($person)) {
|
||||
$class = get_class($person);
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$class = '\Tmdb\Model\Person\CastMember';
|
||||
}
|
||||
|
||||
foreach($data as $item) {
|
||||
foreach ($data as $item) {
|
||||
$collection->add(null, $this->create($item, new $class()));
|
||||
}
|
||||
|
||||
|
|
|
@ -39,12 +39,11 @@ class CrewFactory extends PeopleFactory
|
|||
|
||||
if (is_object($person)) {
|
||||
$class = get_class($person);
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$class = '\Tmdb\Model\Person\CrewMember';
|
||||
}
|
||||
|
||||
foreach($data as $item) {
|
||||
foreach ($data as $item) {
|
||||
$collection->add(null, $this->create($item, new $class()));
|
||||
}
|
||||
|
||||
|
|
|
@ -20,11 +20,8 @@ use Tmdb\Model\Person\CastMember;
|
|||
use Tmdb\Model\Person\CrewMember;
|
||||
use Tmdb\Model\Person;
|
||||
|
||||
/**
|
||||
* Class PeopleFactory
|
||||
* @package Tmdb\Factory
|
||||
*/
|
||||
class PeopleFactory extends AbstractFactory {
|
||||
class PeopleFactory extends AbstractFactory
|
||||
{
|
||||
/**
|
||||
* @var ImageFactory
|
||||
*/
|
||||
|
@ -45,7 +42,7 @@ class PeopleFactory extends AbstractFactory {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param array $data
|
||||
* @param array $data
|
||||
* @param Person\AbstractMember|null $person
|
||||
*
|
||||
* @return Person|CrewMember|CastMember
|
||||
|
@ -97,14 +94,15 @@ class PeopleFactory extends AbstractFactory {
|
|||
/**
|
||||
* Apply credits
|
||||
*
|
||||
* @param array $data
|
||||
* @param array $data
|
||||
* @param Person $person
|
||||
*/
|
||||
protected function applyCredits(array $data = array(), Person $person) {
|
||||
protected function applyCredits(array $data, Person $person)
|
||||
{
|
||||
$hydrator = new ObjectHydrator();
|
||||
$types = array('movie_credits', 'tv_credits', 'combined_credits');
|
||||
|
||||
foreach($types as $type) {
|
||||
foreach ($types as $type) {
|
||||
if (array_key_exists($type, $data)) {
|
||||
$method = $hydrator->camelize(sprintf('get_%s', $type));
|
||||
|
||||
|
@ -114,8 +112,8 @@ class PeopleFactory extends AbstractFactory {
|
|||
new Person\MovieCredit()
|
||||
);
|
||||
|
||||
foreach($cast as $member) {
|
||||
$member->setPosterImage($member->getPosterPath());
|
||||
foreach ($cast as $member) {
|
||||
$member->setPosterImage($this->getPosterImageForCredit($member->getPosterPath()));
|
||||
}
|
||||
|
||||
$person->$method()->setCast($cast);
|
||||
|
@ -127,8 +125,8 @@ class PeopleFactory extends AbstractFactory {
|
|||
new Person\MovieCredit()
|
||||
);
|
||||
|
||||
foreach($crew as $member) {
|
||||
$member->setPosterImage($member->getPosterPath());
|
||||
foreach ($crew as $member) {
|
||||
$member->setPosterImage($this->getPosterImageForCredit($member->getPosterPath()));
|
||||
}
|
||||
|
||||
$person->$method()->setCrew($crew);
|
||||
|
@ -157,24 +155,25 @@ class PeopleFactory extends AbstractFactory {
|
|||
|
||||
if (is_object($person)) {
|
||||
$class = get_class($person);
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$class = '\Tmdb\Model\Person';
|
||||
}
|
||||
|
||||
foreach($data as $item) {
|
||||
foreach ($data as $item) {
|
||||
$collection->add(null, $this->create($item, new $class()));
|
||||
}
|
||||
|
||||
return $collection;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Tmdb\Factory\ImageFactory $imageFactory
|
||||
* @param \Tmdb\Factory\ImageFactory $imageFactory
|
||||
* @return $this
|
||||
*/
|
||||
public function setImageFactory($imageFactory)
|
||||
{
|
||||
$this->imageFactory = $imageFactory;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -187,12 +186,13 @@ class PeopleFactory extends AbstractFactory {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param \Tmdb\Factory\Common\ChangeFactory $changeFactory
|
||||
* @param \Tmdb\Factory\Common\ChangeFactory $changeFactory
|
||||
* @return $this
|
||||
*/
|
||||
public function setChangeFactory($changeFactory)
|
||||
{
|
||||
$this->changeFactory = $changeFactory;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
|
56
modules/Tmdb/Factory/TimezoneFactory.php
Normal file
56
modules/Tmdb/Factory/TimezoneFactory.php
Normal file
|
@ -0,0 +1,56 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of the Tmdb PHP API created by Michael Roterman.
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* @package Tmdb
|
||||
* @author Michael Roterman <michael@wtfz.net>
|
||||
* @copyright (c) 2013, Michael Roterman
|
||||
* @version 0.0.1
|
||||
*/
|
||||
namespace Tmdb\Factory;
|
||||
|
||||
use Tmdb\Model\Collection\Timezones;
|
||||
use Tmdb\Model\Timezone;
|
||||
|
||||
/**
|
||||
* Class TimezoneFactory
|
||||
* @package Tmdb\Factory
|
||||
*/
|
||||
class TimezoneFactory extends AbstractFactory
|
||||
{
|
||||
/**
|
||||
* @param array $data
|
||||
*
|
||||
* @return Timezone\CountryTimezone
|
||||
*/
|
||||
public function create(array $data = array())
|
||||
{
|
||||
return $this->hydrate(new Timezone\CountryTimezone(), $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function createCollection(array $data = array())
|
||||
{
|
||||
$collection = new Timezones();
|
||||
|
||||
foreach ($data as $foobar_data) {
|
||||
foreach ($foobar_data as $iso_3166_1 => $timezones) {
|
||||
$country = new Timezone\CountryTimezone();
|
||||
$country->setIso31661($iso_3166_1);
|
||||
|
||||
foreach ($timezones as $timezone) {
|
||||
$country->getTimezones()->add(null, $timezone);
|
||||
}
|
||||
|
||||
$collection->add(null, $country);
|
||||
}
|
||||
}
|
||||
|
||||
return $collection;
|
||||
}
|
||||
}
|
|
@ -12,6 +12,7 @@
|
|||
*/
|
||||
namespace Tmdb\Factory;
|
||||
|
||||
use Tmdb\Factory\Common\VideoFactory;
|
||||
use Tmdb\Factory\People\CastFactory;
|
||||
use Tmdb\Factory\People\CrewFactory;
|
||||
use Tmdb\Model\Common\GenericCollection;
|
||||
|
@ -24,7 +25,8 @@ use Tmdb\Model\Tv\Episode;
|
|||
* Class TvEpisodeFactory
|
||||
* @package Tmdb\Factory
|
||||
*/
|
||||
class TvEpisodeFactory extends AbstractFactory {
|
||||
class TvEpisodeFactory extends AbstractFactory
|
||||
{
|
||||
/**
|
||||
* @var People\CastFactory
|
||||
*/
|
||||
|
@ -40,6 +42,11 @@ class TvEpisodeFactory extends AbstractFactory {
|
|||
*/
|
||||
private $imageFactory;
|
||||
|
||||
/**
|
||||
* @var Common\VideoFactory
|
||||
*/
|
||||
private $videoFactory;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
|
@ -48,6 +55,7 @@ class TvEpisodeFactory extends AbstractFactory {
|
|||
$this->castFactory = new CastFactory();
|
||||
$this->crewFactory = new CrewFactory();
|
||||
$this->imageFactory = new ImageFactory();
|
||||
$this->videoFactory = new VideoFactory();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -63,16 +71,23 @@ class TvEpisodeFactory extends AbstractFactory {
|
|||
|
||||
if (array_key_exists('credits', $data)) {
|
||||
if (array_key_exists('cast', $data['credits'])) {
|
||||
$tvEpisode->getCredits()->setCast(
|
||||
$this->getCastFactory()->createCollection($data['credits']['cast'],
|
||||
new CastMember())
|
||||
);
|
||||
$tvEpisode
|
||||
->getCredits()
|
||||
->setCast(
|
||||
$this->getCastFactory()
|
||||
->createCollection(
|
||||
$data['credits']['cast'],
|
||||
new CastMember()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if (array_key_exists('crew', $data['credits'])) {
|
||||
$tvEpisode->getCredits()->setCrew(
|
||||
$this->getCrewFactory()->createCollection($data['credits']['crew'],
|
||||
new CrewMember())
|
||||
$this->getCrewFactory()->createCollection(
|
||||
$data['credits']['crew'],
|
||||
new CrewMember()
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -93,6 +108,10 @@ class TvEpisodeFactory extends AbstractFactory {
|
|||
$tvEpisode->setStillImage($this->getImageFactory()->createFromPath($data['still_path'], 'still_path'));
|
||||
}
|
||||
|
||||
if (array_key_exists('videos', $data)) {
|
||||
$tvEpisode->setVideos($this->getVideoFactory()->createCollection($data['videos']));
|
||||
}
|
||||
|
||||
return $this->hydrate($tvEpisode, $data);
|
||||
}
|
||||
|
||||
|
@ -103,7 +122,7 @@ class TvEpisodeFactory extends AbstractFactory {
|
|||
{
|
||||
$collection = new GenericCollection();
|
||||
|
||||
foreach($data as $item) {
|
||||
foreach ($data as $item) {
|
||||
$collection->add(null, $this->create($item));
|
||||
}
|
||||
|
||||
|
@ -111,12 +130,13 @@ class TvEpisodeFactory extends AbstractFactory {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param \Tmdb\Factory\People\CastFactory $castFactory
|
||||
* @param \Tmdb\Factory\People\CastFactory $castFactory
|
||||
* @return $this
|
||||
*/
|
||||
public function setCastFactory($castFactory)
|
||||
{
|
||||
$this->castFactory = $castFactory;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -129,12 +149,13 @@ class TvEpisodeFactory extends AbstractFactory {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param \Tmdb\Factory\People\CrewFactory $crewFactory
|
||||
* @param \Tmdb\Factory\People\CrewFactory $crewFactory
|
||||
* @return $this
|
||||
*/
|
||||
public function setCrewFactory($crewFactory)
|
||||
{
|
||||
$this->crewFactory = $crewFactory;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -147,12 +168,13 @@ class TvEpisodeFactory extends AbstractFactory {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param \Tmdb\Factory\ImageFactory $imageFactory
|
||||
* @param \Tmdb\Factory\ImageFactory $imageFactory
|
||||
* @return $this
|
||||
*/
|
||||
public function setImageFactory($imageFactory)
|
||||
{
|
||||
$this->imageFactory = $imageFactory;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -163,4 +185,23 @@ class TvEpisodeFactory extends AbstractFactory {
|
|||
{
|
||||
return $this->imageFactory;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Tmdb\Factory\Common\VideoFactory $videoFactory
|
||||
* @return $this
|
||||
*/
|
||||
public function setVideoFactory($videoFactory)
|
||||
{
|
||||
$this->videoFactory = $videoFactory;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Tmdb\Factory\Common\VideoFactory
|
||||
*/
|
||||
public function getVideoFactory()
|
||||
{
|
||||
return $this->videoFactory;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
*/
|
||||
namespace Tmdb\Factory;
|
||||
|
||||
use Tmdb\Factory\Common\VideoFactory;
|
||||
use Tmdb\Factory\People\CastFactory;
|
||||
use Tmdb\Factory\People\CrewFactory;
|
||||
use Tmdb\Model\Common\GenericCollection;
|
||||
|
@ -25,7 +26,8 @@ use Tmdb\Model\Tv;
|
|||
* Class TvFactory
|
||||
* @package Tmdb\Factory
|
||||
*/
|
||||
class TvFactory extends AbstractFactory {
|
||||
class TvFactory extends AbstractFactory
|
||||
{
|
||||
/**
|
||||
* @var People\CastFactory
|
||||
*/
|
||||
|
@ -56,6 +58,11 @@ class TvFactory extends AbstractFactory {
|
|||
*/
|
||||
private $networkFactory;
|
||||
|
||||
/**
|
||||
* @var Common\VideoFactory
|
||||
*/
|
||||
private $videoFactory;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
|
@ -67,6 +74,7 @@ class TvFactory extends AbstractFactory {
|
|||
$this->imageFactory = new ImageFactory();
|
||||
$this->tvSeasonFactory = new TvSeasonFactory();
|
||||
$this->networkFactory = new NetworkFactory();
|
||||
$this->videoFactory = new VideoFactory();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -84,11 +92,21 @@ class TvFactory extends AbstractFactory {
|
|||
|
||||
if (array_key_exists('credits', $data)) {
|
||||
if (array_key_exists('cast', $data['credits'])) {
|
||||
$tvShow->getCredits()->setCast($this->getCastFactory()->createCollection($data['credits']['cast'], new CastMember()));
|
||||
$tvShow->getCredits()->setCast(
|
||||
$this->getCastFactory()->createCollection(
|
||||
$data['credits']['cast'],
|
||||
new CastMember()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if (array_key_exists('crew', $data['credits'])) {
|
||||
$tvShow->getCredits()->setCrew($this->getCrewFactory()->createCollection($data['credits']['crew'], new CrewMember()));
|
||||
$tvShow->getCredits()->setCrew(
|
||||
$this->getCrewFactory()->createCollection(
|
||||
$data['credits']['crew'],
|
||||
new CrewMember()
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -106,20 +124,35 @@ class TvFactory extends AbstractFactory {
|
|||
|
||||
/** Images */
|
||||
if (array_key_exists('images', $data)) {
|
||||
$tvShow->setImages($this->getImageFactory()->createCollectionFromTv($data['images']));
|
||||
$tvShow->setImages(
|
||||
$this->getImageFactory()->createCollectionFromTv($data['images'])
|
||||
);
|
||||
}
|
||||
|
||||
if (array_key_exists('backdrop_path', $data)) {
|
||||
$tvShow->setBackdropImage($this->getImageFactory()->createFromPath($data['backdrop_path'], 'backdrop_path'));
|
||||
$tvShow->setBackdropImage(
|
||||
$this->getImageFactory()->createFromPath($data['backdrop_path'], 'backdrop_path')
|
||||
);
|
||||
}
|
||||
|
||||
if (array_key_exists('poster_path', $data)) {
|
||||
$tvShow->setPosterImage($this->getImageFactory()->createFromPath($data['poster_path'], 'poster_path'));
|
||||
$tvShow->setPosterImage(
|
||||
$this->getImageFactory()->createFromPath($data['poster_path'], 'poster_path')
|
||||
);
|
||||
}
|
||||
|
||||
/** Translations */
|
||||
if (array_key_exists('translations', $data) && null !== $data['translations']) {
|
||||
$tvShow->setTranslations($this->createGenericCollection($data['translations']['translations'], new Translation()));
|
||||
|
||||
if (array_key_exists('translations', $data['translations'])) {
|
||||
$translations = $data['translations']['translations'];
|
||||
} else {
|
||||
$translations = $data['translations'];
|
||||
}
|
||||
|
||||
$tvShow->setTranslations(
|
||||
$this->createGenericCollection($translations, new Translation())
|
||||
);
|
||||
}
|
||||
|
||||
/** Seasons */
|
||||
|
@ -132,6 +165,10 @@ class TvFactory extends AbstractFactory {
|
|||
$tvShow->setNetworks($this->getNetworkFactory()->createCollection($data['networks']));
|
||||
}
|
||||
|
||||
if (array_key_exists('videos', $data)) {
|
||||
$tvShow->setVideos($this->getVideoFactory()->createCollection($data['videos']));
|
||||
}
|
||||
|
||||
return $this->hydrate($tvShow, $data);
|
||||
}
|
||||
|
||||
|
@ -146,7 +183,7 @@ class TvFactory extends AbstractFactory {
|
|||
$data = $data['results'];
|
||||
}
|
||||
|
||||
foreach($data as $item) {
|
||||
foreach ($data as $item) {
|
||||
$collection->add(null, $this->create($item));
|
||||
}
|
||||
|
||||
|
@ -154,12 +191,13 @@ class TvFactory extends AbstractFactory {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param \Tmdb\Factory\People\CastFactory $castFactory
|
||||
* @param \Tmdb\Factory\People\CastFactory $castFactory
|
||||
* @return $this
|
||||
*/
|
||||
public function setCastFactory($castFactory)
|
||||
{
|
||||
$this->castFactory = $castFactory;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -172,12 +210,13 @@ class TvFactory extends AbstractFactory {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param \Tmdb\Factory\People\CrewFactory $crewFactory
|
||||
* @param \Tmdb\Factory\People\CrewFactory $crewFactory
|
||||
* @return $this
|
||||
*/
|
||||
public function setCrewFactory($crewFactory)
|
||||
{
|
||||
$this->crewFactory = $crewFactory;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -190,12 +229,13 @@ class TvFactory extends AbstractFactory {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param \Tmdb\Factory\GenreFactory $genreFactory
|
||||
* @param \Tmdb\Factory\GenreFactory $genreFactory
|
||||
* @return $this
|
||||
*/
|
||||
public function setGenreFactory($genreFactory)
|
||||
{
|
||||
$this->genreFactory = $genreFactory;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -208,12 +248,13 @@ class TvFactory extends AbstractFactory {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param \Tmdb\Factory\ImageFactory $imageFactory
|
||||
* @param \Tmdb\Factory\ImageFactory $imageFactory
|
||||
* @return $this
|
||||
*/
|
||||
public function setImageFactory($imageFactory)
|
||||
{
|
||||
$this->imageFactory = $imageFactory;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -226,12 +267,13 @@ class TvFactory extends AbstractFactory {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param \Tmdb\Factory\TvSeasonFactory $tvSeasonFactory
|
||||
* @param \Tmdb\Factory\TvSeasonFactory $tvSeasonFactory
|
||||
* @return $this
|
||||
*/
|
||||
public function setTvSeasonFactory($tvSeasonFactory)
|
||||
{
|
||||
$this->tvSeasonFactory = $tvSeasonFactory;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -244,12 +286,13 @@ class TvFactory extends AbstractFactory {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param \Tmdb\Factory\NetworkFactory $networkFactory
|
||||
* @param \Tmdb\Factory\NetworkFactory $networkFactory
|
||||
* @return $this
|
||||
*/
|
||||
public function setNetworkFactory($networkFactory)
|
||||
{
|
||||
$this->networkFactory = $networkFactory;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -260,4 +303,23 @@ class TvFactory extends AbstractFactory {
|
|||
{
|
||||
return $this->networkFactory;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Tmdb\Factory\Common\VideoFactory $videoFactory
|
||||
* @return $this
|
||||
*/
|
||||
public function setVideoFactory($videoFactory)
|
||||
{
|
||||
$this->videoFactory = $videoFactory;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Tmdb\Factory\Common\VideoFactory
|
||||
*/
|
||||
public function getVideoFactory()
|
||||
{
|
||||
return $this->videoFactory;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
*/
|
||||
namespace Tmdb\Factory;
|
||||
|
||||
use Tmdb\Factory\Common\VideoFactory;
|
||||
use Tmdb\Factory\People\CastFactory;
|
||||
use Tmdb\Factory\People\CrewFactory;
|
||||
use Tmdb\Model\Common\GenericCollection;
|
||||
|
@ -24,7 +25,8 @@ use Tmdb\Model\Tv\Season;
|
|||
* Class TvSeasonFactory
|
||||
* @package Tmdb\Factory
|
||||
*/
|
||||
class TvSeasonFactory extends AbstractFactory {
|
||||
class TvSeasonFactory extends AbstractFactory
|
||||
{
|
||||
/**
|
||||
* @var People\CastFactory
|
||||
*/
|
||||
|
@ -45,6 +47,11 @@ class TvSeasonFactory extends AbstractFactory {
|
|||
*/
|
||||
private $tvEpisodeFactory;
|
||||
|
||||
/**
|
||||
* @var Common\VideoFactory
|
||||
*/
|
||||
private $videoFactory;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
|
@ -54,6 +61,7 @@ class TvSeasonFactory extends AbstractFactory {
|
|||
$this->crewFactory = new CrewFactory();
|
||||
$this->imageFactory = new ImageFactory();
|
||||
$this->tvEpisodeFactory = new TvEpisodeFactory();
|
||||
$this->videoFactory = new VideoFactory();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -69,11 +77,21 @@ class TvSeasonFactory extends AbstractFactory {
|
|||
|
||||
if (array_key_exists('credits', $data)) {
|
||||
if (array_key_exists('cast', $data['credits'])) {
|
||||
$tvSeason->getCredits()->setCast($this->getCastFactory()->createCollection($data['credits']['cast'], new CastMember()));
|
||||
$tvSeason->getCredits()->setCast(
|
||||
$this->getCastFactory()->createCollection(
|
||||
$data['credits']['cast'],
|
||||
new CastMember()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if (array_key_exists('crew', $data['credits'])) {
|
||||
$tvSeason->getCredits()->setCrew($this->getCrewFactory()->createCollection($data['credits']['crew'], new CrewMember()));
|
||||
$tvSeason->getCredits()->setCrew(
|
||||
$this->getCrewFactory()->createCollection(
|
||||
$data['credits']['crew'],
|
||||
new CrewMember()
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -98,6 +116,10 @@ class TvSeasonFactory extends AbstractFactory {
|
|||
$tvSeason->setEpisodes($this->getTvEpisodeFactory()->createCollection($data['episodes']));
|
||||
}
|
||||
|
||||
if (array_key_exists('videos', $data)) {
|
||||
$tvSeason->setVideos($this->getVideoFactory()->createCollection($data['videos']));
|
||||
}
|
||||
|
||||
return $this->hydrate($tvSeason, $data);
|
||||
}
|
||||
|
||||
|
@ -108,7 +130,7 @@ class TvSeasonFactory extends AbstractFactory {
|
|||
{
|
||||
$collection = new GenericCollection();
|
||||
|
||||
foreach($data as $item) {
|
||||
foreach ($data as $item) {
|
||||
$collection->add(null, $this->create($item));
|
||||
}
|
||||
|
||||
|
@ -116,12 +138,13 @@ class TvSeasonFactory extends AbstractFactory {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param \Tmdb\Factory\People\CastFactory $castFactory
|
||||
* @param \Tmdb\Factory\People\CastFactory $castFactory
|
||||
* @return $this
|
||||
*/
|
||||
public function setCastFactory($castFactory)
|
||||
{
|
||||
$this->castFactory = $castFactory;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -134,12 +157,13 @@ class TvSeasonFactory extends AbstractFactory {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param \Tmdb\Factory\People\CrewFactory $crewFactory
|
||||
* @param \Tmdb\Factory\People\CrewFactory $crewFactory
|
||||
* @return $this
|
||||
*/
|
||||
public function setCrewFactory($crewFactory)
|
||||
{
|
||||
$this->crewFactory = $crewFactory;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -152,12 +176,13 @@ class TvSeasonFactory extends AbstractFactory {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param \Tmdb\Factory\ImageFactory $imageFactory
|
||||
* @param \Tmdb\Factory\ImageFactory $imageFactory
|
||||
* @return $this
|
||||
*/
|
||||
public function setImageFactory($imageFactory)
|
||||
{
|
||||
$this->imageFactory = $imageFactory;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -170,12 +195,13 @@ class TvSeasonFactory extends AbstractFactory {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param \Tmdb\Factory\TvEpisodeFactory $tvEpisodeFactory
|
||||
* @param \Tmdb\Factory\TvEpisodeFactory $tvEpisodeFactory
|
||||
* @return $this
|
||||
*/
|
||||
public function setTvEpisodeFactory($tvEpisodeFactory)
|
||||
{
|
||||
$this->tvEpisodeFactory = $tvEpisodeFactory;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -186,4 +212,23 @@ class TvSeasonFactory extends AbstractFactory {
|
|||
{
|
||||
return $this->tvEpisodeFactory;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Tmdb\Factory\Common\VideoFactory $videoFactory
|
||||
* @return $this
|
||||
*/
|
||||
public function setVideoFactory($videoFactory)
|
||||
{
|
||||
$this->videoFactory = $videoFactory;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Tmdb\Factory\Common\VideoFactory
|
||||
*/
|
||||
public function getVideoFactory()
|
||||
{
|
||||
return $this->videoFactory;
|
||||
}
|
||||
}
|
||||
|
|
21
modules/Tmdb/GuestSessionToken.php
Normal file
21
modules/Tmdb/GuestSessionToken.php
Normal file
|
@ -0,0 +1,21 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of the Tmdb PHP API created by Michael Roterman.
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* @package Tmdb
|
||||
* @author Michael Roterman <michael@wtfz.net>
|
||||
* @copyright (c) 2013, Michael Roterman
|
||||
* @version 0.0.1
|
||||
*/
|
||||
namespace Tmdb;
|
||||
|
||||
/**
|
||||
* Class GuestSessionToken
|
||||
* @package Tmdb
|
||||
*/
|
||||
class GuestSessionToken extends SessionToken
|
||||
{
|
||||
}
|
|
@ -19,8 +19,8 @@ use Tmdb\Model\Image;
|
|||
* Class ImageHelper
|
||||
* @package Tmdb\Helper
|
||||
*/
|
||||
class ImageHelper {
|
||||
|
||||
class ImageHelper
|
||||
{
|
||||
private $config;
|
||||
|
||||
public function __construct(Configuration $config)
|
||||
|
@ -41,46 +41,50 @@ class ImageHelper {
|
|||
/**
|
||||
* Get the url for the image resource
|
||||
*
|
||||
* @param Image $image
|
||||
* @param string $size
|
||||
* @param Image|string $image Either an instance of Image or the file_path
|
||||
* @param string $size
|
||||
* @return string
|
||||
*/
|
||||
public function getUrl(Image $image, $size = 'original') {
|
||||
public function getUrl($image, $size = 'original')
|
||||
{
|
||||
$config = $this->getImageConfiguration();
|
||||
|
||||
return $config['base_url'] . $size . $image->getFilePath();
|
||||
return $config['base_url'] . $size . $image;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an img html tag for the image in the specified size
|
||||
*
|
||||
* @param Image $image
|
||||
* @param string $size
|
||||
* @param int|null $width
|
||||
* @param int|null $height
|
||||
* @param Image|string $image Either an instance of Image or the file_path
|
||||
* @param string $size
|
||||
* @param int|null $width
|
||||
* @param int|null $height
|
||||
* @return string
|
||||
*/
|
||||
public function getHtml(Image $image, $size = 'original', $width = null, $height = null) {
|
||||
if (null == $image->getFilePath()) {
|
||||
return '';
|
||||
}
|
||||
public function getHtml($image, $size = 'original', $width = null, $height = null)
|
||||
{
|
||||
if ($image instanceof Image) {
|
||||
if (null == $image->getFilePath()) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$aspectRatio = $image->getAspectRatio();
|
||||
$aspectRatio = $image->getAspectRatio();
|
||||
|
||||
if (null !== $width && null == $height && $aspectRatio !== null) {
|
||||
$height = round($width / $aspectRatio);
|
||||
}
|
||||
if (null !== $width && null == $height && $aspectRatio !== null) {
|
||||
$height = round($width / $aspectRatio);
|
||||
}
|
||||
|
||||
if (null !== $height && null == $width && $aspectRatio !== null) {
|
||||
$width = round($height * $aspectRatio);
|
||||
}
|
||||
if (null !== $height && null == $width && $aspectRatio !== null) {
|
||||
$width = round($height * $aspectRatio);
|
||||
}
|
||||
|
||||
if (null == $width) {
|
||||
$width = $image->getWidth();
|
||||
}
|
||||
if (null == $width) {
|
||||
$width = $image->getWidth();
|
||||
}
|
||||
|
||||
if (null == $height) {
|
||||
$height = $image->getHeight();
|
||||
if (null == $height) {
|
||||
$height = $image->getHeight();
|
||||
}
|
||||
}
|
||||
|
||||
return sprintf(
|
||||
|
|
|
@ -17,13 +17,26 @@ use Guzzle\Http\Message\Request;
|
|||
use Guzzle\Http\Message\RequestInterface;
|
||||
use Guzzle\Http\Message\Response;
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
use Guzzle\Cache\DoctrineCacheAdapter;
|
||||
use Guzzle\Common\Exception\RuntimeException;
|
||||
use Guzzle\Log\MessageFormatter;
|
||||
use Guzzle\Log\PsrLogAdapter;
|
||||
use Guzzle\Plugin\Backoff\BackoffPlugin;
|
||||
use Guzzle\Plugin\Cache\CachePlugin;
|
||||
use Guzzle\Plugin\Cache\DefaultCacheStorage;
|
||||
use Guzzle\Plugin\Log\LogPlugin;
|
||||
use Tmdb\ApiToken;
|
||||
use Tmdb\Exception\TmdbApiException;
|
||||
use Tmdb\HttpClient\Plugin\AcceptJsonHeaderPlugin;
|
||||
use Tmdb\HttpClient\Plugin\ApiTokenPlugin;
|
||||
use Tmdb\HttpClient\Plugin\SessionTokenPlugin;
|
||||
use Tmdb\SessionToken;
|
||||
|
||||
/**
|
||||
* Class HttpClient
|
||||
* @package Tmdb\HttpClient
|
||||
*/
|
||||
class HttpClient
|
||||
implements HttpClientInterface
|
||||
class HttpClient implements HttpClientInterface
|
||||
{
|
||||
/**
|
||||
* @var \Guzzle\Http\ClientInterface
|
||||
|
@ -46,8 +59,8 @@ class HttpClient
|
|||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param string $baseUrl
|
||||
* @param array $options
|
||||
* @param string $baseUrl
|
||||
* @param array $options
|
||||
* @param ClientInterface $client
|
||||
*/
|
||||
public function __construct($baseUrl, array $options, ClientInterface $client)
|
||||
|
@ -55,6 +68,8 @@ class HttpClient
|
|||
$this->base_url = $baseUrl;
|
||||
$this->options = $options;
|
||||
$this->client = $client;
|
||||
|
||||
$this->registerGuzzleSubscribers($options);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -171,11 +186,9 @@ class HttpClient
|
|||
|
||||
try {
|
||||
$response = $request->send();
|
||||
}
|
||||
catch(\Exception $e)
|
||||
{
|
||||
// @TODO catch any API errors / timeouts / other specific information from Guzzle?
|
||||
throw $e;
|
||||
} catch (\Exception $e) {
|
||||
$error = $e->getResponse()->json();
|
||||
throw new TmdbApiException($error['status_message'], $error['status_code']);
|
||||
}
|
||||
|
||||
$this->lastRequest = $request;
|
||||
|
@ -185,12 +198,13 @@ class HttpClient
|
|||
}
|
||||
|
||||
/**
|
||||
* @param \Guzzle\Http\ClientInterface $client
|
||||
* @param \Guzzle\Http\ClientInterface $client
|
||||
* @return $this
|
||||
*/
|
||||
public function setClient($client)
|
||||
{
|
||||
$this->client = $client;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -201,4 +215,166 @@ class HttpClient
|
|||
{
|
||||
return $this->client;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Guzzle\Http\Message\Request $lastRequest
|
||||
* @return $this
|
||||
*/
|
||||
public function setLastRequest($lastRequest)
|
||||
{
|
||||
$this->lastRequest = $lastRequest;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Guzzle\Http\Message\Request
|
||||
*/
|
||||
public function getLastRequest()
|
||||
{
|
||||
return $this->lastRequest;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Guzzle\Http\Message\Response $lastResponse
|
||||
* @return $this
|
||||
*/
|
||||
public function setLastResponse($lastResponse)
|
||||
{
|
||||
$this->lastResponse = $lastResponse;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Guzzle\Http\Message\Response
|
||||
*/
|
||||
public function getLastResponse()
|
||||
{
|
||||
return $this->lastResponse;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current base url
|
||||
*
|
||||
* @return null|string
|
||||
*/
|
||||
public function getBaseUrl()
|
||||
{
|
||||
return $this->getClient()->getBaseUrl();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the base url secure / insecure
|
||||
*
|
||||
* @param $url
|
||||
* @return ClientInterface
|
||||
*/
|
||||
public function setBaseUrl($url)
|
||||
{
|
||||
return $this->getClient()->setBaseUrl($url);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the default subscribers for Guzzle
|
||||
*
|
||||
* @param array $options
|
||||
*/
|
||||
public function registerGuzzleSubscribers(array $options)
|
||||
{
|
||||
$acceptJsonHeaderPlugin = new AcceptJsonHeaderPlugin();
|
||||
$this->addSubscriber($acceptJsonHeaderPlugin);
|
||||
|
||||
$backoffPlugin = BackoffPlugin::getExponentialBackoff(5);
|
||||
$this->addSubscriber($backoffPlugin);
|
||||
|
||||
if (array_key_exists('token', $options) && $options['token'] instanceof ApiToken) {
|
||||
$apiTokenPlugin = new ApiTokenPlugin($options['token']);
|
||||
$this->addSubscriber($apiTokenPlugin);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an subscriber to enable caching.
|
||||
*
|
||||
* @param array $parameters
|
||||
* @throws \Guzzle\Common\Exception\RuntimeException
|
||||
*/
|
||||
public function setCaching(array $parameters = array())
|
||||
{
|
||||
if (!class_exists('Doctrine\Common\Cache\FilesystemCache')) {
|
||||
//@codeCoverageIgnoreStart
|
||||
throw new RuntimeException(
|
||||
'Could not find the doctrine cache library,
|
||||
have you added doctrine-cache to your composer.json?'
|
||||
);
|
||||
//@codeCoverageIgnoreEnd
|
||||
}
|
||||
|
||||
$cachePlugin = new CachePlugin(array(
|
||||
'storage' => new DefaultCacheStorage(
|
||||
new DoctrineCacheAdapter(
|
||||
new \Doctrine\Common\Cache\FilesystemCache($parameters['cache_path'])
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
$this->addSubscriber($cachePlugin);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an subscriber to enable logging.
|
||||
*
|
||||
* @param array $parameters
|
||||
* @throws \Guzzle\Common\Exception\RuntimeException
|
||||
*/
|
||||
public function setLogging(array $parameters = array())
|
||||
{
|
||||
if (!array_key_exists('logger', $parameters) && !class_exists('\Monolog\Logger')) {
|
||||
//@codeCoverageIgnoreStart
|
||||
throw new RuntimeException(
|
||||
'Could not find any logger set and the monolog logger library was not found
|
||||
to provide a default, you have to set a custom logger on the client or
|
||||
have you forgot adding monolog to your composer.json?'
|
||||
);
|
||||
//@codeCoverageIgnoreEnd
|
||||
} else {
|
||||
$logger = new \Monolog\Logger('php-tmdb-api');
|
||||
$logger->pushHandler(
|
||||
new \Monolog\Handler\StreamHandler(
|
||||
$parameters['log_path'],
|
||||
\Monolog\Logger::DEBUG
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if (array_key_exists('logger', $parameters)) {
|
||||
$logger = $parameters['logger'];
|
||||
}
|
||||
|
||||
$logPlugin = null;
|
||||
|
||||
if ($logger instanceof \Psr\Log\LoggerInterface) {
|
||||
$logPlugin = new LogPlugin(
|
||||
new PsrLogAdapter($logger),
|
||||
MessageFormatter::SHORT_FORMAT
|
||||
);
|
||||
}
|
||||
|
||||
if (null !== $logPlugin) {
|
||||
$this->addSubscriber($logPlugin);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an subscriber to append the session_token to the query parameters.
|
||||
*
|
||||
* @param SessionToken $sessionToken
|
||||
*/
|
||||
public function setSessionToken(SessionToken $sessionToken)
|
||||
{
|
||||
$sessionTokenPlugin = new SessionTokenPlugin($sessionToken);
|
||||
$this->addSubscriber($sessionTokenPlugin);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@ namespace Tmdb\HttpClient;
|
|||
|
||||
use Guzzle\Http\Message\RequestInterface;
|
||||
use Guzzle\Http\Message\Response;
|
||||
use Tmdb\SessionToken;
|
||||
|
||||
/**
|
||||
* Interface HttpClientInterface
|
||||
|
@ -24,71 +25,71 @@ interface HttpClientInterface
|
|||
/**
|
||||
* Compose a GET request
|
||||
*
|
||||
* @param string $path Request path
|
||||
* @param array $parameters GET Parameters
|
||||
* @param array $headers Reconfigure the request headers for this call only
|
||||
* @param string $path Request path
|
||||
* @param array $parameters GET Parameters
|
||||
* @param array $headers Reconfigure the request headers for this call only
|
||||
*
|
||||
* @return Response Data
|
||||
* @return Response Data
|
||||
*/
|
||||
public function get($path, array $parameters = array(), array $headers = array());
|
||||
|
||||
/**
|
||||
* Compose a POST request
|
||||
*
|
||||
* @param string $path Request path
|
||||
* @param string $postBody The post BODY
|
||||
* @param array $parameters POST Parameters
|
||||
* @param array $headers Reconfigure the request headers for this call only
|
||||
* @param string $path Request path
|
||||
* @param string $postBody The post BODY
|
||||
* @param array $parameters POST Parameters
|
||||
* @param array $headers Reconfigure the request headers for this call only
|
||||
*
|
||||
* @return Response Data
|
||||
* @return Response Data
|
||||
*/
|
||||
public function post($path, $postBody, array $parameters = array(), array $headers = array());
|
||||
|
||||
/**
|
||||
* Compose a POST request but json_encode the body
|
||||
*
|
||||
* @param string $path Request path
|
||||
* @param array $postBody The post BODY
|
||||
* @param array $parameters POST Parameters
|
||||
* @param array $headers Reconfigure the request headers for this call only
|
||||
* @param string $path Request path
|
||||
* @param array $postBody The post BODY
|
||||
* @param array $parameters POST Parameters
|
||||
* @param array $headers Reconfigure the request headers for this call only
|
||||
*
|
||||
* @return Response Data
|
||||
* @return Response Data
|
||||
*/
|
||||
public function postJson($path, $postBody, array $parameters = array(), array $headers = array());
|
||||
|
||||
/**
|
||||
* Compose a PATCH request
|
||||
*
|
||||
* @param string $path Request path
|
||||
* @param string $body The body
|
||||
* @param array $parameters PATCH Parameters
|
||||
* @param array $headers Reconfigure the request headers for this call only
|
||||
* @param string $path Request path
|
||||
* @param string $body The body
|
||||
* @param array $parameters PATCH Parameters
|
||||
* @param array $headers Reconfigure the request headers for this call only
|
||||
*
|
||||
* @return Response Data
|
||||
* @return Response Data
|
||||
*/
|
||||
public function patch($path, $body = null, array $parameters = array(), array $headers = array());
|
||||
|
||||
/**
|
||||
* Compose a PUT request
|
||||
*
|
||||
* @param string $path Request path
|
||||
* @param string $body The body
|
||||
* @param array $parameters PUT Parameters
|
||||
* @param array $headers Reconfigure the request headers for this call only
|
||||
* @param string $path Request path
|
||||
* @param string $body The body
|
||||
* @param array $parameters PUT Parameters
|
||||
* @param array $headers Reconfigure the request headers for this call only
|
||||
*
|
||||
* @return Response Data
|
||||
* @return Response Data
|
||||
*/
|
||||
public function put($path, $body = null, array $parameters = array(), array $headers = array());
|
||||
|
||||
/**
|
||||
* Compose a DELETE request
|
||||
*
|
||||
* @param string $path Request path
|
||||
* @param string $body The body
|
||||
* @param array $parameters DELETE Parameters
|
||||
* @param array $headers Reconfigure the request headers for this call only
|
||||
* @param string $path Request path
|
||||
* @param string $body The body
|
||||
* @param array $parameters DELETE Parameters
|
||||
* @param array $headers Reconfigure the request headers for this call only
|
||||
*
|
||||
* @return Response Data
|
||||
* @return Response Data
|
||||
*/
|
||||
public function delete($path, $body = null, array $parameters = array(), array $headers = array());
|
||||
|
||||
|
@ -100,4 +101,8 @@ interface HttpClientInterface
|
|||
*/
|
||||
public function request(RequestInterface $request);
|
||||
|
||||
public function getBaseUrl();
|
||||
public function setBaseUrl($url);
|
||||
|
||||
public function setSessionToken(SessionToken $sessionToken);
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@ namespace Tmdb\HttpClient\Plugin;
|
|||
|
||||
use Guzzle\Common\Event;
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
use Tmdb\GuestSessionToken;
|
||||
use Tmdb\SessionToken;
|
||||
|
||||
/**
|
||||
|
@ -41,7 +42,11 @@ class SessionTokenPlugin implements EventSubscriberInterface
|
|||
{
|
||||
$url = $event['request']->getUrl(true);
|
||||
|
||||
$url->getQuery()->set('session_id', $this->token->getToken());
|
||||
if ($this->token instanceof GuestSessionToken) {
|
||||
$url->getQuery()->set('guest_session_id', $this->token->getToken());
|
||||
} else {
|
||||
$url->getQuery()->set('session_id', $this->token->getToken());
|
||||
}
|
||||
|
||||
$event['request']->setUrl($url);
|
||||
}
|
||||
|
|
|
@ -16,12 +16,12 @@ namespace Tmdb\Model;
|
|||
* Class AbstractModel
|
||||
* @package Tmdb\Model
|
||||
*/
|
||||
class AbstractModel {
|
||||
class AbstractModel
|
||||
{
|
||||
/**
|
||||
* List of properties to populate by the ObjectHydrator
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $_properties = array();
|
||||
|
||||
public static $properties = array();
|
||||
}
|
||||
|
|
|
@ -16,7 +16,8 @@ namespace Tmdb\Model;
|
|||
* Class Account
|
||||
* @package Tmdb\Model
|
||||
*/
|
||||
class Account extends AbstractModel {
|
||||
class Account extends AbstractModel
|
||||
{
|
||||
/**
|
||||
* @var integer
|
||||
*/
|
||||
|
@ -50,7 +51,7 @@ class Account extends AbstractModel {
|
|||
/**
|
||||
* @var array
|
||||
*/
|
||||
public static $_properties = array(
|
||||
public static $properties = array(
|
||||
'id',
|
||||
'include_adult',
|
||||
'iso_3166_1',
|
||||
|
@ -60,12 +61,13 @@ class Account extends AbstractModel {
|
|||
);
|
||||
|
||||
/**
|
||||
* @param int $id
|
||||
* @param int $id
|
||||
* @return $this
|
||||
*/
|
||||
public function setId($id)
|
||||
{
|
||||
$this->id = $id;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -78,12 +80,13 @@ class Account extends AbstractModel {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param boolean $includeAdult
|
||||
* @param boolean $includeAdult
|
||||
* @return $this
|
||||
*/
|
||||
public function setIncludeAdult($includeAdult)
|
||||
{
|
||||
$this->includeAdult = $includeAdult;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -96,12 +99,13 @@ class Account extends AbstractModel {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param string $iso31661
|
||||
* @param string $iso31661
|
||||
* @return $this
|
||||
*/
|
||||
public function setIso31661($iso31661)
|
||||
{
|
||||
$this->iso31661 = $iso31661;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -114,12 +118,13 @@ class Account extends AbstractModel {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param string $iso6391
|
||||
* @param string $iso6391
|
||||
* @return $this
|
||||
*/
|
||||
public function setIso6391($iso6391)
|
||||
{
|
||||
$this->iso6391 = $iso6391;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -132,12 +137,13 @@ class Account extends AbstractModel {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @param string $name
|
||||
* @return $this
|
||||
*/
|
||||
public function setName($name)
|
||||
{
|
||||
$this->name = $name;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -150,12 +156,13 @@ class Account extends AbstractModel {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param string $username
|
||||
* @param string $username
|
||||
* @return $this
|
||||
*/
|
||||
public function setUsername($username)
|
||||
{
|
||||
$this->username = $username;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -166,6 +173,4 @@ class Account extends AbstractModel {
|
|||
{
|
||||
return $this->username;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -19,7 +19,8 @@ use Tmdb\Model\Image\PosterImage;
|
|||
* Class ListItem
|
||||
* @package Tmdb\Model\Account
|
||||
*/
|
||||
class ListItem extends AbstractModel {
|
||||
class ListItem extends AbstractModel
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
|
@ -68,7 +69,7 @@ class ListItem extends AbstractModel {
|
|||
/**
|
||||
* @var array
|
||||
*/
|
||||
public static $_properties = array(
|
||||
public static $properties = array(
|
||||
'description',
|
||||
'favorite_count',
|
||||
'id',
|
||||
|
@ -80,12 +81,13 @@ class ListItem extends AbstractModel {
|
|||
);
|
||||
|
||||
/**
|
||||
* @param string $description
|
||||
* @param string $description
|
||||
* @return $this
|
||||
*/
|
||||
public function setDescription($description)
|
||||
{
|
||||
$this->description = $description;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -98,12 +100,13 @@ class ListItem extends AbstractModel {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param int $favoriteCount
|
||||
* @param int $favoriteCount
|
||||
* @return $this
|
||||
*/
|
||||
public function setFavoriteCount($favoriteCount)
|
||||
{
|
||||
$this->favoriteCount = $favoriteCount;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -116,12 +119,13 @@ class ListItem extends AbstractModel {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param string $id
|
||||
* @param string $id
|
||||
* @return $this
|
||||
*/
|
||||
public function setId($id)
|
||||
{
|
||||
$this->id = $id;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -134,12 +138,13 @@ class ListItem extends AbstractModel {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param string $iso6391
|
||||
* @param string $iso6391
|
||||
* @return $this
|
||||
*/
|
||||
public function setIso6391($iso6391)
|
||||
{
|
||||
$this->iso6391 = $iso6391;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -152,12 +157,13 @@ class ListItem extends AbstractModel {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param int $itemCount
|
||||
* @param int $itemCount
|
||||
* @return $this
|
||||
*/
|
||||
public function setItemCount($itemCount)
|
||||
{
|
||||
$this->itemCount = $itemCount;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -170,12 +176,13 @@ class ListItem extends AbstractModel {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param string $listType
|
||||
* @param string $listType
|
||||
* @return $this
|
||||
*/
|
||||
public function setListType($listType)
|
||||
{
|
||||
$this->listType = $listType;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -188,12 +195,13 @@ class ListItem extends AbstractModel {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @param string $name
|
||||
* @return $this
|
||||
*/
|
||||
public function setName($name)
|
||||
{
|
||||
$this->name = $name;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -206,12 +214,13 @@ class ListItem extends AbstractModel {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param \Tmdb\Model\Image\PosterImage $posterImage
|
||||
* @param \Tmdb\Model\Image\PosterImage $posterImage
|
||||
* @return $this
|
||||
*/
|
||||
public function setPosterImage($posterImage)
|
||||
{
|
||||
$this->posterImage = $posterImage;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -224,12 +233,13 @@ class ListItem extends AbstractModel {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param string $posterPath
|
||||
* @param string $posterPath
|
||||
* @return $this
|
||||
*/
|
||||
public function setPosterPath($posterPath)
|
||||
{
|
||||
$this->posterPath = $posterPath;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
|
|
@ -18,8 +18,8 @@ use Tmdb\Model\Common\GenericCollection;
|
|||
* Class Certification
|
||||
* @package Tmdb\Model
|
||||
*/
|
||||
class Certification extends AbstractModel {
|
||||
|
||||
class Certification extends AbstractModel
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
|
@ -30,7 +30,7 @@ class Certification extends AbstractModel {
|
|||
*/
|
||||
private $certifications;
|
||||
|
||||
public static $_properties = array(
|
||||
public static $properties = array(
|
||||
'country',
|
||||
);
|
||||
|
||||
|
@ -40,12 +40,13 @@ class Certification extends AbstractModel {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param \Tmdb\Model\Common\GenericCollection $certifications
|
||||
* @param \Tmdb\Model\Common\GenericCollection $certifications
|
||||
* @return $this
|
||||
*/
|
||||
public function setCertifications($certifications)
|
||||
{
|
||||
$this->certifications = $certifications;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -58,12 +59,13 @@ class Certification extends AbstractModel {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param string $country
|
||||
* @param string $country
|
||||
* @return $this
|
||||
*/
|
||||
public function setCountry($country)
|
||||
{
|
||||
$this->country = $country;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
|
|
@ -18,8 +18,8 @@ use Tmdb\Model\AbstractModel;
|
|||
* Class CountryCertification
|
||||
* @package Tmdb\Model\Certification
|
||||
*/
|
||||
class CountryCertification extends AbstractModel {
|
||||
|
||||
class CountryCertification extends AbstractModel
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
|
@ -35,19 +35,20 @@ class CountryCertification extends AbstractModel {
|
|||
*/
|
||||
private $order;
|
||||
|
||||
public static $_properties = array(
|
||||
public static $properties = array(
|
||||
'certification',
|
||||
'meaning',
|
||||
'order',
|
||||
);
|
||||
|
||||
/**
|
||||
* @param string $certification
|
||||
* @param string $certification
|
||||
* @return $this
|
||||
*/
|
||||
public function setCertification($certification)
|
||||
{
|
||||
$this->certification = $certification;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -60,12 +61,13 @@ class CountryCertification extends AbstractModel {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param string $meaning
|
||||
* @param string $meaning
|
||||
* @return $this
|
||||
*/
|
||||
public function setMeaning($meaning)
|
||||
{
|
||||
$this->meaning = $meaning;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -78,12 +80,13 @@ class CountryCertification extends AbstractModel {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param int $order
|
||||
* @param int $order
|
||||
* @return $this
|
||||
*/
|
||||
public function setOrder($order)
|
||||
{
|
||||
$this->order = $order;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -94,6 +97,4 @@ class CountryCertification extends AbstractModel {
|
|||
{
|
||||
return $this->order;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -16,7 +16,8 @@ namespace Tmdb\Model;
|
|||
* Class Change
|
||||
* @package Tmdb\Model
|
||||
*/
|
||||
class Change extends AbstractModel {
|
||||
class Change extends AbstractModel
|
||||
{
|
||||
/**
|
||||
* @var integer
|
||||
*/
|
||||
|
@ -30,18 +31,19 @@ class Change extends AbstractModel {
|
|||
/**
|
||||
* @var array
|
||||
*/
|
||||
public static $_properties = array(
|
||||
public static $properties = array(
|
||||
'id',
|
||||
'adult'
|
||||
);
|
||||
|
||||
/**
|
||||
* @param boolean $adult
|
||||
* @param boolean $adult
|
||||
* @return $this
|
||||
*/
|
||||
public function setAdult($adult)
|
||||
{
|
||||
$this->adult = (bool) $adult;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -54,12 +56,13 @@ class Change extends AbstractModel {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param int $id
|
||||
* @param int $id
|
||||
* @return $this
|
||||
*/
|
||||
public function setId($id)
|
||||
{
|
||||
$this->id = (int) $id;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
|
|
@ -21,8 +21,8 @@ use Tmdb\Model\Image\PosterImage;
|
|||
* Class Collection
|
||||
* @package Tmdb\Model
|
||||
*/
|
||||
class Collection extends AbstractModel {
|
||||
|
||||
class Collection extends AbstractModel
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
|
@ -68,7 +68,7 @@ class Collection extends AbstractModel {
|
|||
*/
|
||||
private $poster;
|
||||
|
||||
public static $_properties = array(
|
||||
public static $properties = array(
|
||||
'backdrop_path',
|
||||
'id',
|
||||
'name',
|
||||
|
@ -83,12 +83,13 @@ class Collection extends AbstractModel {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param \Tmdb\Model\Image\BackdropImage $backdrop
|
||||
* @param \Tmdb\Model\Image\BackdropImage $backdrop
|
||||
* @return $this
|
||||
*/
|
||||
public function setBackdropImage(BackdropImage $backdrop)
|
||||
{
|
||||
$this->backdrop = $backdrop;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -101,12 +102,13 @@ class Collection extends AbstractModel {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param string $backdropPath
|
||||
* @param string $backdropPath
|
||||
* @return $this
|
||||
*/
|
||||
public function setBackdropPath($backdropPath)
|
||||
{
|
||||
$this->backdropPath = $backdropPath;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -119,12 +121,13 @@ class Collection extends AbstractModel {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param int $id
|
||||
* @param int $id
|
||||
* @return $this
|
||||
*/
|
||||
public function setId($id)
|
||||
{
|
||||
$this->id = (int) $id;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -137,12 +140,13 @@ class Collection extends AbstractModel {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param \Tmdb\Model\Collection\Images $images
|
||||
* @param \Tmdb\Model\Collection\Images $images
|
||||
* @return $this
|
||||
*/
|
||||
public function setImages(Images $images)
|
||||
{
|
||||
$this->images = $images;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -155,12 +159,13 @@ class Collection extends AbstractModel {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @param string $name
|
||||
* @return $this
|
||||
*/
|
||||
public function setName($name)
|
||||
{
|
||||
$this->name = $name;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -173,12 +178,13 @@ class Collection extends AbstractModel {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param string $overview
|
||||
* @param string $overview
|
||||
* @return $this
|
||||
*/
|
||||
public function setOverview($overview)
|
||||
{
|
||||
$this->overview = $overview;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -191,12 +197,13 @@ class Collection extends AbstractModel {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param GenericCollection $parts
|
||||
* @param GenericCollection $parts
|
||||
* @return $this
|
||||
*/
|
||||
public function setParts($parts)
|
||||
{
|
||||
$this->parts = $parts;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -209,12 +216,13 @@ class Collection extends AbstractModel {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param \Tmdb\Model\Image\PosterImage $poster
|
||||
* @param \Tmdb\Model\Image\PosterImage $poster
|
||||
* @return $this
|
||||
*/
|
||||
public function setPosterImage(PosterImage $poster)
|
||||
{
|
||||
$this->poster = $poster;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -227,12 +235,13 @@ class Collection extends AbstractModel {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param string $posterPath
|
||||
* @param string $posterPath
|
||||
* @return $this
|
||||
*/
|
||||
public function setPosterPath($posterPath)
|
||||
{
|
||||
$this->posterPath = $posterPath;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue