Update searchId function in TraktAPI

This commit is contained in:
DariusIII
2015-10-30 09:38:22 +01:00
parent faaa1b3d2e
commit cb0d567b6a
2 changed files with 21 additions and 7 deletions
+1
View File
@@ -1,4 +1,5 @@
2015-10-30 DariusIII
Upd: searchId function in TraktAPI
Upd: Change the ordering of TV processing
2015-10-29 DariusIII
Fix: Fix the firstaired request
+20 -7
View File
@@ -226,21 +226,34 @@ HEADERS;
* Search for entry using on of the supported site IDs.
*
* @param integer $id The ID to look for.
* @param string $type Site whose ID should be searched for.
* @param string $site One of the supported sites ('imdb', 'tmdb', 'trakt', 'tvdb', 'tvrage')
* @param string $type videos.type flag (-1 for episodes).
*
* @return bool
*/
public function searchId($id, $type = 'trakt')
public function searchId($id, $site = 'trakt', $type = 0)
{
if (!in_array($type, $this->types) || !ctype_digit($id)) {
return false;
}
if ($type == 'imdb') {
if (!in_array($site, $this->types) || !ctype_digit($id)) {
return null;
} else if ($site == 'imdb') {
$id = 'tt' . $id;
}
switch (true) {
case $site == 'trakt' && ($type == 0 || $type == 2):
$type = $site . '-show';
break;
case $site == 'trakt' && $type == 1:
$type = $site . '-movie';
break;
case $site == 'trakt' && $type == -1:
$type = $site . '-episode';
break;
default:
}
$url = self::API_URL . "search?id_type=$type&id=$id";
return $this->getJsonArray($url, '');
}