From cb0d567b6a7e9870524b5d2089c0d69a2ade49ea Mon Sep 17 00:00:00 2001 From: DariusIII Date: Fri, 30 Oct 2015 09:38:22 +0100 Subject: [PATCH] Update searchId function in TraktAPI --- Changelog | 1 + newznab/libraries/TraktAPI.php | 27 ++++++++++++++++++++------- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/Changelog b/Changelog index cd6320b3d..450b01303 100755 --- a/Changelog +++ b/Changelog @@ -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 diff --git a/newznab/libraries/TraktAPI.php b/newznab/libraries/TraktAPI.php index b44160dfc..c20d16b8f 100644 --- a/newznab/libraries/TraktAPI.php +++ b/newznab/libraries/TraktAPI.php @@ -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, ''); }