diff --git a/Changelog b/Changelog index 297793eeb..05a296c7d 100755 --- a/Changelog +++ b/Changelog @@ -1,3 +1,5 @@ +2015-11-15 DariusIII + Chg: Numerous TV related fixes ported from nZEDb 2015-11-12 DariusIII Fix: Remove timeZone as tmdb is already UTC Upd: Update TV episodes parsing diff --git a/libs/Moinax/TVDB/Episode.php b/libs/Moinax/TVDB/Episode.php index 02cf74033..6858587b7 100644 --- a/libs/Moinax/TVDB/Episode.php +++ b/libs/Moinax/TVDB/Episode.php @@ -110,7 +110,7 @@ class Episode $this->season = (int)$data->SeasonNumber; $this->directors = (array)Client::removeEmptyIndexes(explode('|', (string)$data->Director)); $this->name = (string)$data->EpisodeName; - $this->firstAired = (string)$data->FirstAired !== '' ? new \DateTime((string)$data->FirstAired) : null; + $this->firstAired = (string)$data->FirstAired !== '' ? (string)$data->FirstAired : null; $this->guestStars = Client::removeEmptyIndexes(explode('|', (string)$data->GuestStars)); $this->imdbId = (string)$data->IMDB_ID; $this->language = (string) $data->Language; diff --git a/libs/Moinax/TVDB/Serie.php b/libs/Moinax/TVDB/Serie.php index d0e13a371..9b99f2078 100644 --- a/libs/Moinax/TVDB/Serie.php +++ b/libs/Moinax/TVDB/Serie.php @@ -147,7 +147,7 @@ class Serie $this->name = (string)$data->SeriesName; $this->banner = (string)$data->banner; $this->overview = (string)$data->Overview; - $this->firstAired = new \DateTime((string)$data->FirstAired); + $this->firstAired = (string)$data->FirstAired; $this->imdbId = (string)$data->IMDB_ID; $this->actors = (array)Client::removeEmptyIndexes(explode('|', (string)$data->Actors)); $this->airsDayOfWeek = (string)$data->Airs_DayOfWeek; diff --git a/misc/testing/DB/reset_postprocessing.php b/misc/testing/DB/reset_postprocessing.php index 525f2251d..79c86b4ca 100755 --- a/misc/testing/DB/reset_postprocessing.php +++ b/misc/testing/DB/reset_postprocessing.php @@ -24,7 +24,7 @@ if (isset($argv[1]) && $argv[1] === "all") { $pdo->queryExec("TRUNCATE TABLE releaseextrafull"); $pdo->queryExec("TRUNCATE TABLE xxxinfo"); $pdo->queryExec("TRUNCATE TABLE videos"); - $pdo->queryExec("TRUNCATE TABLE videos_akas"); + $pdo->queryExec("TRUNCATE TABLE videos_aliases"); $pdo->queryExec("TRUNCATE TABLE tv_info"); $pdo->queryExec("TRUNCATE TABLE tv_episodes"); $pdo->queryExec("TRUNCATE TABLE anidb_info"); @@ -188,7 +188,7 @@ if (isset($argv[1]) && ($argv[1] === "misc" || $argv[1] === "all")) { if (isset($argv[1]) && ($argv[1] === "tv" || $argv[1] === "all")) { $ran = true; if (isset($argv[3]) && $argv[3] === "truncate") { - $pdo->queryExec("DELETE v, va FROM videos v INNER JOIN videos_akas va ON v.id = va.videos_id WHERE type = 0"); + $pdo->queryExec("DELETE v, va FROM videos v INNER JOIN videos_aliases va ON v.id = va.videos_id WHERE type = 0"); $pdo->queryExec("TRUNCATE TABLE tv_info"); $pdo->queryExec("TRUNCATE TABLE tv_episodes"); } diff --git a/newznab/ReleaseExtra.php b/newznab/ReleaseExtra.php index 41a8b5065..3a684bf18 100644 --- a/newznab/ReleaseExtra.php +++ b/newznab/ReleaseExtra.php @@ -32,27 +32,34 @@ class ReleaseExtra */ public function makeCodecPretty($codec) { - if (preg_match('/DX50|DIVX|DIV3/i', $codec)) { - return 'DivX'; - } - if (preg_match('/XVID/i', $codec)) { - return 'XviD'; - } - if (preg_match('/^27$/i', $codec)) { - return 'Blu-Ray'; - } - if (preg_match('/V_MPEG4\/ISO\/AVC/i', $codec)) { - return 'x264'; - } - if (preg_match('/wmv|WVC1/i', $codec)) { - return 'wmv'; - } - if (preg_match('/^2$/i', $codec)) { - return 'HD.ts'; - } - if (preg_match('/avc1/i', $codec)) { - return 'h.264'; + switch (true) { + case preg_match('#(?:^36$|HEVC)#i', $codec): + $codec = 'HEVC'; + break; + case preg_match('#(?:^(?:7|27|H264)$|AVC)#i', $codec); + $codec = 'h.264'; + break; + case preg_match('#(?:^(?:20|FMP4|MP42|MP43|MPG4)$|ASP)#i', $codec): + $codec = 'MPEG-4'; + break; + case preg_match('#^2$#i', $codec); + $codec = 'MPEG-2'; + break; + case preg_match('#^MPEG$#', $codec); + $codec = 'MPEG-1'; + break; + case preg_match('#DX50|DIVX|DIV3#i', $codec): + $codec = 'DivX'; + break; + case preg_match('#XVID#i', $codec): + $codec = 'XviD'; + break; + case preg_match('#(?:wmv|WVC1)#i', $codec); + $codec = 'wmv'; + break; + default; } + return $codec; } diff --git a/newznab/processing/PostProcess.php b/newznab/processing/PostProcess.php index e9f8fe168..ca5af5627 100755 --- a/newznab/processing/PostProcess.php +++ b/newznab/processing/PostProcess.php @@ -264,7 +264,7 @@ class PostProcess (new TVDB(['Echo' => $this->echooutput, 'Settings' => $this->pdo]))->processTVDB($groupID, $guidChar, $processTV); (new TVMaze(['Echo' => $this->echooutput, 'Settings' => $this->pdo]))->processTVMaze($groupID, $guidChar, $processTV); (new TMDB(['Echo' => $this->echooutput, 'Settings' => $this->pdo]))->processTMDB($groupID, $guidChar, $processTV); - (new TraktTv(['Echo' => $this->echooutput, 'Settings' => $this->pdo]))->processTrakt($groupID, $guidChar, $processTV); + //(new TraktTv(['Echo' => $this->echooutput, 'Settings' => $this->pdo]))->processTrakt($groupID, $guidChar, $processTV); //(new TvRage(['Echo' => $this->echooutput, 'Settings' => $this->pdo]))->processTvRage($groupID, $guidChar, $processTV); } } diff --git a/newznab/processing/Videos.php b/newznab/processing/Videos.php index e807cb26c..3561ad118 100644 --- a/newznab/processing/Videos.php +++ b/newznab/processing/Videos.php @@ -39,11 +39,20 @@ abstract class Videos */ public $pdo; + /** + * @var bool + */ + public $echooutput; + /** * @var array sites The sites that we have an ID columns for in our video table. */ private $sites = ['imdb', 'tmdb', 'trakt', 'tvdb', 'tvmaze', 'tvrage']; + /** + * @var array Temp Array of cached failed lookups + */ + public $titleCache; public function __construct(array $options = []) { @@ -54,11 +63,24 @@ abstract class Videos $options += $defaults; // Sets the default timezone for this script (and its children). - date_default_timezone_set('UTC'); + //date_default_timezone_set('UTC'); TODO: Make this a DTO instead and use as needed + $this->echooutput = ($options['Echo'] && NN_ECHOCLI); $this->pdo = ($options['Settings'] instanceof Settings ? $options['Settings'] : new Settings()); + $this->titleCache = []; } + /** + * Main processing director function for scrapers + * Calls work query function and initiates processing + * + * @param $groupID + * @param $guidChar + * @param $process + * @param bool $local + */ + abstract protected function processSite($groupID, $guidChar, $process, $local = false); + /** * Get video info from a Site ID and column. * @@ -104,28 +126,28 @@ abstract class Videos * @param $type * @param int $source * - * @return bool + * @return false|int */ public function getByTitle($title, $type, $source = 0) { // Check if we already have an entry for this show. - $res = $this->getByTitleQuery($title, $type, $source); + $res = $this->getTitleExact($title, $type, $source); if (isset($res['id'])) { return $res['id']; } $title2 = str_replace(' and ', ' & ', $title); if ($title != $title2) { - $res = $this->getByTitleQuery($title2, $type, $source); + $res = $this->getTitleExact($title2, $type, $source); if (isset($res['id'])) { return $res['id']; } $pieces = explode(' ', $title2); - $title4 = '%'; + $title2 = '%'; foreach ($pieces as $piece) { - $title4 .= str_replace(["'", "!"], "", $piece) . '%'; + $title2 .= str_replace(["'", "!"], "", $piece) . '%'; } - $res = $this->getByTitleLikeQuery($title4, $type, $source); + $res = $this->getTitleLoose($title2, $type, $source); if (isset($res['id'])) { return $res['id']; } @@ -133,18 +155,18 @@ abstract class Videos // Some words are spelled correctly 2 ways // example theatre and theater - $title3 = str_replace('er', 're', $title); - if ($title != $title3) { - $res = $this->getByTitleQuery($title3, $type, $source); + $title2 = str_replace('er', 're', $title); + if ($title != $title2) { + $res = $this->getTitleExact($title2, $type, $source); if (isset($res['id'])) { return $res['id']; } - $pieces = explode(' ', $title3); - $title4 = '%'; + $pieces = explode(' ', $title2); + $title2 = '%'; foreach ($pieces as $piece) { - $title4 .= str_replace(["'", "!"], "", $piece) . '%'; + $title2 .= str_replace(["'", "!"], "", $piece) . '%'; } - $res = $this->getByTitleLikeQuery($title4, $type, $source); + $res = $this->getTitleLoose($title2, $type, $source); if (isset($res['id'])) { return $res['id']; } @@ -155,11 +177,11 @@ abstract class Videos // Only search if the title contains more than one word to prevent incorrect matches $pieces = explode(' ', $title); if (count($pieces) > 1) { - $title4 = '%'; + $title2 = '%'; foreach ($pieces as $piece) { - $title4 .= str_replace(["'", "!"], "", $piece) . '%'; + $title2 .= str_replace(["'", "!"], "", $piece) . '%'; } - $res = $this->getByTitleLikeQuery($title4, $type, $source); + $res = $this->getTitleLoose($title2, $type, $source); if (isset($res['id'])) { return $res['id']; } @@ -174,17 +196,17 @@ abstract class Videos * @param $type * @param int $source * - * @return array|bool + * @return array|false */ - public function getByTitleQuery($title, $type, $source = 0) + public function getTitleExact($title, $type, $source = 0) { $return = false; - if ($title) { + if (!empty($title)) { $return = $this->pdo->queryOneRow( sprintf(" SELECT v.id FROM videos v - LEFT JOIN videos_akas va ON v.id = va.videos_id + LEFT JOIN videos_aliases va ON v.id = va.videos_id WHERE (v.title = %1\$s OR va.title = %1\$s) AND v.type = %2\$d %3\$s", $this->pdo->escapeString($title), @@ -203,18 +225,18 @@ abstract class Videos * @param $type * @param int $source * - * @return array|bool + * @return array|false */ - public function getByTitleLikeQuery($title, $type, $source = 0) + public function getTitleLoose($title, $type, $source = 0) { $return = false; - if ($title) { + if (!empty($title)) { $return = $this->pdo->queryOneRow( sprintf(" SELECT v.id FROM videos v - LEFT JOIN videos_akas va ON v.id = va.videos_id + LEFT JOIN videos_aliases va ON v.id = va.videos_id WHERE (v.title %1\$s OR va.title %1\$s) AND type = %2\$d %3\$s", @@ -231,19 +253,19 @@ abstract class Videos * Inserts aliases for videos * * @param $videoId - * @param array $aliasArr + * @param array $aliases */ - public function addAliases($videoId, $aliasArr = array()) + public function addAliases($videoId, array $aliases = []) { - if (!empty($aliasArr) && $videoId > 0) { - foreach ($aliasArr AS $key => $title) { + if (!empty($aliases) && $videoId > 0) { + foreach ($aliases AS $key => $title) { // Check if we have the AKA already $check = $this->getAliases(0, $title); if ($check === false) { $this->pdo->queryInsert( sprintf(' - INSERT INTO videos_akas + INSERT IGNORE INTO videos_aliases (videos_id, title) VALUES (%d, %s)', $videoId, @@ -261,7 +283,7 @@ abstract class Videos * @param int $videoId * @param string $alias * - * @return bool|\PDOStatement + * @return \PDOStatement|false */ public function getAliases($videoId = 0, $alias = '') { @@ -277,90 +299,10 @@ abstract class Videos if ($sql !== '') { $return = $this->pdo->query(' SELECT * - FROM videos_akas - WHERE ' . $sql, true + FROM videos_aliases + WHERE ' . $sql, true, NN_CACHE_EXPIRY_MEDIUM ); } return (empty($return) ? false : $return); } - - /** - * This function turns a roman numeral into an integer - * - * @param string $string - * - * @return int $e - */ - public function convertRomanToInt($string) { - switch ($string) { - case 'i': $e = 1; - break; - case 'ii': $e = 2; - break; - case 'iii': $e = 3; - break; - case 'iv': $e = 4; - break; - case 'v': $e = 5; - break; - case 'vi': $e = 6; - break; - case 'vii': $e = 7; - break; - case 'viii': $e = 8; - break; - case 'ix': $e = 9; - break; - case 'x': $e = 10; - break; - case 'xi': $e = 11; - break; - case 'xii': $e = 12; - break; - case 'xiii': $e = 13; - break; - case 'xiv': $e = 14; - break; - case 'xv': $e = 15; - break; - case 'xvi': $e = 16; - break; - case 'xvii': $e = 17; - break; - case 'xviii': $e = 18; - break; - case 'xix': $e = 19; - break; - case 'xx': $e = 20; - break; - default: - $e = 0; - } - return $e; - } - - /** - * Get a country code for a country name. - * - * @param string $country - * - * @return mixed - */ - public function countryCode($country) - { - if (!is_array($country) && strlen($country) > 2) { - $code = $this->pdo->queryOneRow( - sprintf(' - SELECT id - FROM countries - WHERE country = %s', - $this->pdo->escapeString($country) - ) - ); - if (isset($code['id'])) { - return $code['id']; - } - } - return ''; - } } diff --git a/newznab/processing/tv/TMDB.php b/newznab/processing/tv/TMDB.php index df9ad8f3b..956c5b11e 100644 --- a/newznab/processing/tv/TMDB.php +++ b/newznab/processing/tv/TMDB.php @@ -8,17 +8,6 @@ class TMDB extends TV { const MATCH_PROBABILITY = 75; - - /** - * @string DateTimeZone Object - UTC - */ - private $timeZone; - - /** - * @string MySQL DATETIME Format - */ - private $timeFormat; - /** * @var string The URL for the image for poster */ @@ -35,8 +24,6 @@ class TMDB extends TV { parent::__construct($options); $this->client = new TmdbAPI($this->pdo->getSetting('tmdbkey')); - $this->timeZone = new \DateTimeZone('UTC'); - $this->timeFormat = 'Y-m-d H:i:s'; } /** @@ -56,14 +43,14 @@ class TMDB extends TV * Main processing director function for TMDB * Calls work query function and initiates processing * - * @param $groupID - * @param $guidChar - * @param $processTV - * @param bool|false $local + * @param $groupID + * @param $guidChar + * @param $process + * @param bool $local */ - public function processTMDB ($groupID, $guidChar, $processTV, $local = false) + public function processSite ($groupID, $guidChar, $process, $local = false) { - $res = $this->getTvReleases($groupID, $guidChar, $processTV, parent::PROCESS_TMDB); + $res = $this->getTvReleases($groupID, $guidChar, $process, parent::PROCESS_TMDB); $tvcount = $res->rowCount(); @@ -72,16 +59,29 @@ class TMDB extends TV } if ($res instanceof \Traversable) { + + $this->titleCache = []; + foreach ($res as $row) { $this->posterUrl = ''; $tmdbid = false; // Clean the show name for better match probability - $release = $this->parseShowInfo($row['searchname']); + $release = $this->parseInfo($row['searchname']); if (is_array($release) && $release['name'] != '') { + if (in_array($release['cleanname'], $this->titleCache)) { + if ($this->echooutput) { + echo $this->pdo->log->headerOver("Title: ") . + $this->pdo->log->warningOver('"' . $release['cleanname'] . '"') . + $this->pdo->log->header(" already failed lookup for this site. Skipping."); + } + $this->setVideoNotFound(parent::PROCESS_TRAKT, $row['id']); + continue; + } + // Find the Video ID if it already exists by checking the title against stored TMDB titles $videoId = $this->getByTitle($release['cleanname'], parent::TYPE_TV, parent::SOURCE_TMDB); @@ -104,7 +104,7 @@ class TMDB extends TV $tmdbShow = $this->getShowInfo((string)$release['cleanname']); if (is_array($tmdbShow)) { - // Check if we have the TVDB ID already, if we do use that Video ID + // Check if we have the TMDB ID already, if we do use that Video ID $dupeCheck = $this->getVideoIDFromSiteID('tvdb', $tmdbShow['tvdb']); if ($dupeCheck === false) { $videoId = $this->add($tmdbShow); @@ -168,10 +168,21 @@ class TMDB extends TV echo $this->pdo->log->primary("Found TMDB Match!"); } continue; + } else { + //Processing failed, set the episode ID to the next processing group + $this->setVideoNotFound(parent::PROCESS_TRAKT, $row['id']); + $this->titleCache[] = $release['cleanname']; } + } else { + //Processing failed, set the episode ID to the next processing group + $this->setVideoNotFound(parent::PROCESS_TRAKT, $row['id']); + $this->titleCache[] = $release['cleanname']; } - } //Processing failed, set the episode ID to the next processing group - $this->setVideoNotFound(parent::PROCESS_TRAKT, $row['id']); + } else{ + //Processing failed, set the episode ID to the next processing group + $this->setVideoNotFound(parent::PROCESS_TRAKT, $row['id']); + $this->titleCache[] = $release['cleanname']; + } } } } @@ -182,7 +193,7 @@ class TMDB extends TV * * @param $cleanName * - * @return array|bool + * @return array|false */ protected function getShowInfo($cleanName) { @@ -199,18 +210,18 @@ class TMDB extends TV } /** - * @param $showArr + * @param $shows * @param $cleanName * - * @return array|bool + * @return array|false */ - private function matchShowInfo($showArr, $cleanName) + private function matchShowInfo($shows, $cleanName) { $return = false; $highestMatch = 0; - foreach ($showArr AS $show) { - if ($this->checkRequired($show->_data, 'tmdbS')) { + foreach ($shows AS $show) { + if ($this->checkRequiredAttr($show->_data, 'tmdbS')) { // Check for exact title match first and then terminate if found if (strtolower($show->_data['name']) === strtolower($cleanName)) { $highest = $show; @@ -229,14 +240,14 @@ class TMDB extends TV } if (isset($highest)) { $showAppends = $this->client->getTVShow($highest->_data['id'], 'append_to_response=alternative_titles,external_ids'); - if ($showAppends) { + if (isset($showAppends->_data['alternative_titles']['results']) && is_array($showAppends->_data['alternative_titles']['results'])) { foreach ($showAppends->_data['alternative_titles']['results'] AS $aka) { $highest->_data['alternative_titles'][] = $aka['title']; } $highest->_data['network'] = (isset($showAppends->_data['networks'][0]['name']) ? $showAppends->_data['networks'][0]['name'] : ''); $highest->_data['external_ids'] = $showAppends->_data['external_ids']; } - $return = $this->formatShowArr($highest); + $return = $this->formatShowInfo($highest); } return $return; } @@ -284,8 +295,8 @@ class TMDB extends TV //Handle Single Episode Lookups if (is_object($response)) { - if ($this->checkRequired($response->_data, 'tmdbE')) { - $return = $this->formatEpisodeArr($response); + if ($this->checkRequiredAttr($response->_data, 'tmdbE')) { + $return = $this->formatEpisodeInfo($response); } } return $return; @@ -299,7 +310,7 @@ class TMDB extends TV * * @return array */ - private function formatShowArr($show) + protected function formatShowInfo($show) { $this->posterUrl = $this->client->getImageURL() . (string)(isset($show->_data['poster_path']) ? $show->_data['poster_path'] : ''); @@ -313,7 +324,7 @@ class TMDB extends TV 'summary' => (string)$show->_data['overview'], 'started' => (string)$show->_data['first_air_date'], 'publisher' => (isset($show->_data['network']) ? (string)$show->_data['network'] : ''), - 'country' => (string)$show->_data['origin_country'][0], + 'country' => (string)(isset($show->_data['origin_country'][0]) ? $show->_data['origin_country'][0] : ''), 'source' => (int)parent::SOURCE_TMDB, 'imdb' => (isset($imdb['imdbid']) ? (int)$imdb['imdbid'] : 0), 'tvdb' => (isset($show->_data['external_ids']['tvdb_id']) ? (int)$show->_data['external_ids']['tvdb_id'] : 0), @@ -333,7 +344,7 @@ class TMDB extends TV * * @return array */ - private function formatEpisodeArr($episode) + protected function formatEpisodeInfo($episode) { return [ 'title' => (string)$episode->_data['name'], diff --git a/newznab/processing/tv/TV.php b/newznab/processing/tv/TV.php index d020c1e9b..03442b029 100644 --- a/newznab/processing/tv/TV.php +++ b/newznab/processing/tv/TV.php @@ -2,6 +2,8 @@ namespace newznab\processing\tv; use newznab\processing\Videos; +use newznab\utility\Country; +use newznab\utility\Utility; /** * Class TV -- abstract extension of Videos @@ -10,30 +12,26 @@ use newznab\processing\Videos; abstract class TV extends Videos { // Television Sources - const SOURCE_NONE = 0; // No Scrape source - const SOURCE_TVDB = 1; // Scrape source was TVDB - const SOURCE_TVMAZE = 2; // Scrape source was TVMAZE - const SOURCE_TMDB = 3; // Scrape source was TMDB - const SOURCE_TRAKT = 4; // Scrape source was Trakt - const SOURCE_IMDB = 5; // Scrape source was IMDB - const SOURCE_TVRAGE = 6; // Scrape source was TvRage + const SOURCE_NONE = 0; // No Scrape source + const SOURCE_TVDB = 1; // Scrape source was TVDB + const SOURCE_TVMAZE = 2; // Scrape source was TVMAZE + const SOURCE_TMDB = 3; // Scrape source was TMDB + const SOURCE_TRAKT = 4; // Scrape source was Trakt + const SOURCE_IMDB = 5; // Scrape source was IMDB + const SOURCE_TVRAGE = 6; // Scrape source was TvRage // Anime Sources - const SOURCE_ANIDB = 10; // Scrape source was AniDB + const SOURCE_ANIDB = 10; // Scrape source was AniDB // Processing signifiers - const PROCESS_TVDB = 0; // Process TVDB First - const PROCESS_TVMAZE = -1; // Process TVMaze Second - const PROCESS_TMDB = -2; // Process TMDB Third - const PROCESS_TRAKT = -3; // Process Trakt Fourth - const PROCESS_IMDB = -4; // Process IMDB Fifth - const PROCESS_TVRAGE = -5; // Process TvRage Sixth - const NO_MATCH_FOUND = -6; // Failed All Methods - - /** - * @var bool - */ - public $echooutput; + const PROCESS_TVDB = 0; // Process TVDB First + const PROCESS_TVMAZE = -1; // Process TVMaze Second + const PROCESS_TMDB = -2; // Process TMDB Third + const PROCESS_TRAKT = -3; // Process Trakt Fourth + const PROCESS_IMDB = -4; // Process IMDB Fifth + const PROCESS_TVRAGE = -5; // Process TvRage Sixth + const NO_MATCH_FOUND = -6; // Failed All Methods + const FAILED_PARSE = -100; // Failed Parsing /** * @var int @@ -56,13 +54,6 @@ abstract class TV extends Videos public function __construct(array $options = []) { parent::__construct($options); - $defaults = [ - 'Echo' => false, - 'Settings' => null, - ]; - $options += $defaults; - - $this->echooutput = ($options['Echo'] && NN_ECHOCLI); $this->catWhere = 'categoryid BETWEEN 5000 AND 5999 AND categoryid NOT IN (5070)'; $this->tvqty = ($this->pdo->getSetting('maxrageprocessed') != '') ? $this->pdo->getSetting('maxrageprocessed') : 75; $this->imgSavePath = NN_COVERS . 'tvshows' . DS; @@ -110,6 +101,26 @@ abstract class TV extends Videos abstract protected function getShowInfo($name); /** + * Assigns API show response values to a formatted array for insertion + * Returns the formatted array + * + * @param $show + * + * @return array + */ + abstract protected function formatShowInfo($show); + + /** + * Assigns API episode response values to a formatted array for insertion + * Returns the formatted array + * + * @param $episode + * + * @return array + */ + abstract protected function formatEpisodeInfo($episode); + + /** * Retrieve releases for TV processing * Returns a PDO Object of rows or false if none found * @@ -118,7 +129,7 @@ abstract class TV extends Videos * @param int $lookupSetting -- whether or not to use the API * @param int $status -- release processing status of tv_episodes_id * - * @return bool|int|\PDOStatement + * @return false|int|\PDOStatement */ public function getTvReleases($groupID = '', $guidChar = '', $lookupSetting = 1, $status = 0) { @@ -197,24 +208,24 @@ abstract class TV extends Videos * Inserts a new video ID into the database for TV shows * If a duplicate is found it is handle by calling update instead * - * @param array $showArr + * @param array $show * * @return int */ - public function add($showArr = array()) + public function add(array $show = []) { $videoId = false; // Check if the country is not a proper code and retrieve if not - if ($showArr['country'] !== '' && strlen($showArr['country']) > 2) { - $showArr['country'] = $this->countryCode($showArr['country']); + if ($show['country'] !== '' && strlen($show['country']) > 2) { + $show['country'] = Country::countryCode($show['country'], $this->pdo); } // Check if video already exists based on site ID info // if that fails be sure we're not inserting duplicates by checking the title foreach ($this->siteColumns AS $column) { - if ($showArr[$column] > 0) { - $videoId = $this->getVideoIDFromSiteID($column, $showArr[$column]); + if ($show[$column] > 0) { + $videoId = $this->getVideoIDFromSiteID($column, $show[$column]); } if ($videoId !== false) { break; @@ -228,17 +239,17 @@ abstract class TV extends Videos INSERT INTO videos (type, title, countries_id, started, source, tvdb, trakt, tvrage, tvmaze, imdb, tmdb) VALUES (%d, %s, %s, %s, %d, %d, %d, %d, %d, %d, %d)', - $showArr['type'], - $this->pdo->escapeString($showArr['title']), - $this->pdo->escapeString((isset($showArr['country']) ? $showArr['country'] : '')), - $this->pdo->escapeString($showArr['started']), - $showArr['source'], - $showArr['tvdb'], - $showArr['trakt'], - $showArr['tvrage'], - $showArr['tvmaze'], - $showArr['imdb'], - $showArr['tmdb'] + $show['type'], + $this->pdo->escapeString($show['title']), + $this->pdo->escapeString((isset($show['country']) ? $show['country'] : '')), + $this->pdo->escapeString($show['started']), + $show['source'], + $show['tvdb'], + $show['trakt'], + $show['tvrage'], + $show['tvmaze'], + $show['imdb'], + $show['tmdb'] ) ); // Insert the supplementary show info @@ -247,17 +258,17 @@ abstract class TV extends Videos INSERT INTO tv_info (videos_id, summary, publisher) VALUES (%d, %s, %s)", $videoId, - $this->pdo->escapeString($showArr['summary']), - $this->pdo->escapeString($showArr['publisher']) + $this->pdo->escapeString($show['summary']), + $this->pdo->escapeString($show['publisher']) ) ); // If we have AKAs\aliases, insert those as well - if (!empty($showArr['aliases'])) { - $this->addAliases($videoId, $showArr['aliases']); + if (!empty($show['aliases'])) { + $this->addAliases($videoId, $show['aliases']); } } else { // If a local match was found, just update missing video info - $this->update($videoId, $showArr); + $this->update($videoId, $show); } return (int)$videoId; } @@ -266,13 +277,13 @@ abstract class TV extends Videos * Inserts a new TV episode into the tv_episodes table following a match to a Video ID * * @param int $videoId - * @param array $episodeArr + * @param array $episode * * @return false|int|string */ - public function addEpisode($videoId, $episodeArr = array()) + public function addEpisode($videoId, array $episode = []) { - $episodeId = $this->getBySeasonEp($videoId, $episodeArr['series'], $episodeArr['episode'], $episodeArr['firstaired']); + $episodeId = $this->getBySeasonEp($videoId, $episode['series'], $episode['episode'], $episode['firstaired']); if ($episodeId === false) { $episodeId = $this->pdo->queryInsert( @@ -281,13 +292,13 @@ abstract class TV extends Videos VALUES (%d, %d, %d, %s, %s, %s, %s) ON DUPLICATE KEY update se_complete = %s', $videoId, - $episodeArr['series'], - $episodeArr['episode'], - $this->pdo->escapeString($episodeArr['se_complete']), - $this->pdo->escapeString($episodeArr['title']), - $this->pdo->escapeString($episodeArr['firstaired']), - $this->pdo->escapeString($episodeArr['summary']), - $this->pdo->escapeString($episodeArr['se_complete']) + $episode['series'], + $episode['episode'], + $this->pdo->escapeString($episode['se_complete']), + $this->pdo->escapeString($episode['title']), + $this->pdo->escapeString($episode['firstaired']), + $this->pdo->escapeString($episode['summary']), + $this->pdo->escapeString($episode['se_complete']) ) ); } @@ -298,13 +309,13 @@ abstract class TV extends Videos * Updates the show info with data from the supplied array * Only called when a duplicate show is found during insert * - * @param int $videoId - * @param array $showArr + * @param int $videoId + * @param array $show */ - public function update($videoId, $showArr = array()) + public function update($videoId, array $show = []) { - if ($showArr['country'] !== '') { - $showArr['country'] = $this->countryCode($showArr['country']); + if ($show['country'] !== '') { + $show['country'] = Country::countryCode($show['country'], $this->pdo); } $ifStringID = 'IF(%s = 0, %s, %s)'; @@ -318,20 +329,20 @@ abstract class TV extends Videos v.tvmaze = %s, v.imdb = %s, v.tmdb = %s, tvi.summary = %s, tvi.publisher = %s WHERE v.id = %d', - sprintf($ifStringInfo, 'v.countries_id', $this->pdo->escapeString($showArr['country']), 'v.countries_id'), - sprintf($ifStringID, 'v.tvdb', $showArr['tvdb'], 'v.tvdb'), - sprintf($ifStringID, 'v.trakt', $showArr['trakt'], 'v.trakt'), - sprintf($ifStringID, 'v.tvrage', $showArr['tvrage'], 'v.tvrage'), - sprintf($ifStringID, 'v.tvmaze', $showArr['tvmaze'], 'v.tvmaze'), - sprintf($ifStringID, 'v.imdb', $showArr['imdb'], 'v.imdb'), - sprintf($ifStringID, 'v.tmdb', $showArr['tmdb'], 'v.tmdb'), - sprintf($ifStringInfo, 'tvi.summary', $this->pdo->escapeString($showArr['summary']), 'tvi.summary'), - sprintf($ifStringInfo, 'tvi.publisher', $this->pdo->escapeString($showArr['publisher']), 'tvi.publisher'), + sprintf($ifStringInfo, 'v.countries_id', $this->pdo->escapeString($show['country']), 'v.countries_id'), + sprintf($ifStringID, 'v.tvdb', $show['tvdb'], 'v.tvdb'), + sprintf($ifStringID, 'v.trakt', $show['trakt'], 'v.trakt'), + sprintf($ifStringID, 'v.tvrage', $show['tvrage'], 'v.tvrage'), + sprintf($ifStringID, 'v.tvmaze', $show['tvmaze'], 'v.tvmaze'), + sprintf($ifStringID, 'v.imdb', $show['imdb'], 'v.imdb'), + sprintf($ifStringID, 'v.tmdb', $show['tmdb'], 'v.tmdb'), + sprintf($ifStringInfo, 'tvi.summary', $this->pdo->escapeString($show['summary']), 'tvi.summary'), + sprintf($ifStringInfo, 'tvi.publisher', $this->pdo->escapeString($show['publisher']), 'tvi.publisher'), $videoId ) ); - if (!empty($showArr['aliases'])) { - $this->addAliases($videoId, $showArr['aliases']); + if (!empty($show['aliases'])) { + $this->addAliases($videoId, $show['aliases']); } } @@ -340,17 +351,17 @@ abstract class TV extends Videos * * @param $id * - * @return bool|\PDOStatement + * @return \PDOStatement|false */ public function delete($id) { return $this->pdo->queryExec( sprintf(" - DELETE v, tvi, tve + DELETE v, tvi, tve, va FROM videos v LEFT JOIN tv_info tvi ON v.id = tvi.videos_id LEFT JOIN tv_episodes tve ON v.id = tve.videos_id - LEFT JOIN videos_akas va ON v.id = va.videos_id + LEFT JOIN videos_aliases va ON v.id = va.videos_id WHERE v.id = %d", $id ) @@ -381,12 +392,12 @@ abstract class TV extends Videos * @param string $column * @param int $id * - * @return array|bool + * @return \PDOStatement|false */ public function getSiteByID($column, $id) { $return = false; - $videoArr = $this->pdo->queryOneRow( + $video = $this->pdo->queryOneRow( sprintf(" SELECT %s FROM videos @@ -396,9 +407,9 @@ abstract class TV extends Videos ) ); if ($column === '*') { - $return = $videoArr; - } else if ($column !== '*' && isset($videoArr[$column])) { - $return = $videoArr[$column]; + $return = $video; + } else if ($column !== '*' && isset($video[$column])) { + $return = $video[$column]; } return $return; } @@ -414,7 +425,7 @@ abstract class TV extends Videos * @param $episode * @param string $airdate * - * @return int|bool + * @return int|false */ public function getBySeasonEp($id, $series, $episode, $airdate = '') { @@ -465,26 +476,25 @@ abstract class TV extends Videos * * @param $relname * - * @return array|bool + * @return array|false */ - public function parseShowInfo($relname) + public function parseInfo($relname) { - $showInfo['name'] = $this->parseShowName($relname); + $showInfo['name'] = $this->parseName($relname); if (!empty($showInfo['name'])) { // Retrieve the country from the cleaned name - $showInfo['country'] = $this->parseShowCountry($showInfo['name']); + $showInfo['country'] = $this->parseCountry($showInfo['name']); // Clean show name. $showInfo['cleanname'] = preg_replace('/ - \d{1,}$/i', '', $this->cleanName($showInfo['name'])); // Get the Season/Episode/Airdate - $showInfo += $this->parseShowSeasonEp($relname); + $showInfo += $this->parseSeasonEp($relname); - if ((isset($showInfo['season']) && isset($showInfo['episode'])) || !empty($showInfo['airdate'])) { - // Check for dates instead of seasons. - if (!isset($showInfo['airdate']) && !empty($showInfo['airdate'])) { + if ((isset($showInfo['season']) && isset($showInfo['episode'])) || isset($showInfo['airdate'])) { + if (!isset($showInfo['airdate'])) { // If year is present in the release name, add it to the cleaned name for title search if (preg_match('/[^a-z0-9](?P(19|20)(\d{2}))[^a-z0-9]/i', $relname, $yearMatch)) { $showInfo['cleanname'] .= ' (' . $yearMatch['year'] . ')'; @@ -512,7 +522,7 @@ abstract class TV extends Videos * * @return string */ - private function parseShowName($relname) + private function parseName($relname) { $showName = ''; @@ -521,7 +531,7 @@ abstract class TV extends Videos 'S\d+[^a-z0-9]?((E\d+)[ab]?)*|WEB[-_. ]?(DL|Rip)|XViD)[^a-z0-9]'; // For names that don't start with the title. - if (preg_match('/([^a-z0-9]{2,}|(sample|proof)-)(?P[\w .-]*?)' . $following . '/i', $relname, $matches)) { + if (preg_match('/^([^a-z0-9]{2,}|(sample|proof|repost)-)(?P[\w .-]*?)' . $following . '/i', $relname, $matches)) { $showName = $matches['name']; } else if (preg_match('/^(?P[a-z0-9][\w .-]*?)' . $following . '/i', $relname, $matches)) { // For names that start with the title. @@ -537,19 +547,19 @@ abstract class TV extends Videos * * @return array */ - private function parseShowSeasonEp($relname) + private function parseSeasonEp($relname) { - $episodeArr['airdate'] = ''; + $episodeArr = []; // S01E01-E02 and S01E01-02 if (preg_match('/^(.*?)[^a-z0-9]s(\d{1,2})[^a-z0-9]?e(\d{1,3})(?:[e-])(\d{1,3})[^a-z0-9]/i', $relname, $matches)) { $episodeArr['season'] = intval($matches[2]); - $episodeArr['episode'] = intval($matches[3]); + $episodeArr['episode'] = [intval($matches[3]), intval($matches[4])]; } //S01E0102 and S01E01E02 - lame no delimit numbering, regex would collide if there was ever 1000 ep season. else if (preg_match('/^(.*?)[^a-z0-9]s(\d{2})[^a-z0-9]?e(\d{2})e?(\d{2})[^a-z0-9]/i', $relname, $matches)) { $episodeArr['season'] = intval($matches[2]); - $episodeArr['episode'] = [intval($matches[3]), intval($matches[4])]; + $episodeArr['episode'] = intval($matches[3]); } // S01E01 and S01.E01 else if (preg_match('/^(.*?)[^a-z0-9]s(\d{1,2})[^a-z0-9]?e(\d{1,3})[ab]?[^a-z0-9]/i', $relname, $matches)) { @@ -567,7 +577,7 @@ abstract class TV extends Videos $episodeArr['episode'] = 'all'; } // 1x01 and 101 - else if (preg_match('/^(.*?)[^a-z0-9](\d{1,2})x?(\d{1,3})[^a-z0-9]/i', $relname, $matches)) { + else if (preg_match('/^(.*?)[^a-z0-9](\d{1,2})x(\d{1,3})[^a-z0-9]/i', $relname, $matches)) { $episodeArr['season'] = intval($matches[2]); $episodeArr['episode'] = intval($matches[3]); } @@ -610,7 +620,7 @@ abstract class TV extends Videos else if (preg_match('/^(.*?)[^a-z0-9](?:Part|Pt)[^a-z0-9]([ivx]+)/i', $relname, $matches)) { $episodeArr['season'] = 1; $epLow = strtolower($matches[2]); - $episodeArr['episode'] = $this->convertRomanToInt($epLow); + $episodeArr['episode'] = Utility::convertRomanToInt($epLow); } // Band.Of.Brothers.EP06.Bastogne.DVDRiP.XviD-DEiTY else if (preg_match('/^(.*?)[^a-z0-9]EP?[^a-z0-9]?(\d{1,3})/i', $relname, $matches)) { @@ -632,9 +642,8 @@ abstract class TV extends Videos * * @return string */ - private function parseShowCountry($showName) + private function parseCountry($showName) { - $countryMatch = $yearMatch = ''; // Country or origin matching. if (preg_match('/[^a-z0-9](US|UK|AU|NZ|CA|NL|Canada|Australia|America|United[^a-z0-9]States|United[^a-z0-9]Kingdom)/i', $showName, $countryMatch)) { $currentCountry = strtolower($countryMatch[1]); @@ -656,7 +665,7 @@ abstract class TV extends Videos } /** - * Supplementary to parseShowInfo + * Supplementary to parseInfo * Cleans a derived local 'showname' for better matching probability * Returns the cleaned string * @@ -694,7 +703,7 @@ abstract class TV extends Videos * @param $scrapeName * @param $probability * - * @return bool|float + * @return int|float */ public function checkMatch($ourName, $scrapeName, $probability) { @@ -740,12 +749,12 @@ abstract class TV extends Videos * Checks API response returns have all REQUIRED attributes set * Returns true or false * - * @param array $array + * @param $array * @param int $type * * @return bool */ - public function checkRequired($array = array(), $type) + public function checkRequiredAttr($array, $type) { $required = ['failedToMatchType']; @@ -768,12 +777,6 @@ abstract class TV extends Videos case 'tmdbE': $required = ['name', 'season_number', 'episode_number', 'air_date', 'overview']; break; - case 'traktS': - $required = ['ids', 'title', 'overview', 'first_aired', 'country']; - break; - case 'traktE': - $required = ['title', 'season', 'number', 'airs', 'overview']; - break; } if (is_array($required)) { diff --git a/newznab/processing/tv/TVDB.php b/newznab/processing/tv/TVDB.php index 6fbfb2902..6d9bc6d54 100644 --- a/newznab/processing/tv/TVDB.php +++ b/newznab/processing/tv/TVDB.php @@ -3,6 +3,7 @@ namespace newznab\processing\tv; use libs\Moinax\TVDB\Client; use libs\Moinax\TVDB\CurlException; +use libs\Moinax\TVDB\XmlException; use newznab\ReleaseImage; /** @@ -35,9 +36,9 @@ class TVDB extends TV private $serverTime; /** - * @string MySQL DATETIME Format + * @bool Do a local lookup only if server is down */ - private $timeFormat; + private $local; /** * @param array $options Class instances / Echo to cli? @@ -48,23 +49,37 @@ class TVDB extends TV $this->client = new Client(self::TVDB_URL, self::TVDB_API_KEY); $this->posterUrl = self::TVDB_URL . DS . 'banners/_cache/posters/%s-1.jpg'; $this->fanartUrl = self::TVDB_URL . DS . 'banners/_cache/fanart/original/%s-1.jpg'; + $this->local = false; - $this->serverTime = $this->client->getServerTime(); - $this->timeFormat = 'Y-m-d H:i:s'; + // Check if we can get the time for API status + // If we can't then we set local to true + try { + $this->serverTime = $this->client->getServerTime(); + } catch (CurlException $error) { + if (strpos($error->getMessage(), 'Cannot fetch') === 0) { + echo $this->pdo->log->warning('Could not reach TVDB API. Running in local mode only!'); + $this->local = true; + } + } catch (XmlException $error) { + if (strpos($error->getMessage(), 'Error in file') === 0) { + echo $this->pdo->log->warning('Could not reach TVDB API. Running in local mode only!'); + $this->local = true; + } + } } /** - * Main processing director function for TVDB + * Main processing director function for scrapers * Calls work query function and initiates processing * - * @param $groupID - * @param $guidChar - * @param $processTV - * @param bool|false $local + * @param $groupID + * @param $guidChar + * @param $process + * @param bool $local */ - public function processTVDB($groupID, $guidChar, $processTV, $local = false) + public function processSite($groupID, $guidChar, $process, $local = false) { - $res = $this->getTvReleases($groupID, $guidChar, $processTV, parent::PROCESS_TVDB); + $res = $this->getTvReleases($groupID, $guidChar, $process, parent::PROCESS_TVDB); $tvcount = $res->rowCount(); @@ -73,14 +88,27 @@ class TVDB extends TV } if ($res instanceof \Traversable) { + + $this->titleCache = []; + foreach ($res as $row) { $tvdbid = false; // Clean the show name for better match probability - $release = $this->parseShowInfo($row['searchname']); + $release = $this->parseInfo($row['searchname']); if (is_array($release) && $release['name'] != '') { + if (in_array($release['cleanname'], $this->titleCache)) { + if ($this->echooutput) { + echo $this->pdo->log->headerOver("Title: ") . + $this->pdo->log->warningOver('"' . $release['cleanname'] . '"') . + $this->pdo->log->header(" already failed lookup for this site. Skipping."); + } + $this->setVideoNotFound(parent::PROCESS_TVMAZE, $row['id']); + continue; + } + // Find the Video ID if it already exists by checking the title. $videoId = $this->getByTitle($release['cleanname'], parent::TYPE_TV); @@ -89,7 +117,7 @@ class TVDB extends TV } // Force local lookup only - if ($local == true) { + if ($local === true || $this->local === true) { $lookupSetting = false; } else { $lookupSetting = true; @@ -167,11 +195,21 @@ class TVDB extends TV if ($this->echooutput) { echo $this->pdo->log->primary("Found TVDB Match!"); } - continue; + } else { + //Processing failed, set the episode ID to the next processing group + $this->setVideoNotFound(parent::PROCESS_TVMAZE, $row['id']); + $this->titleCache[] = $release['cleanname']; } + } else { + //Processing failed, set the episode ID to the next processing group + $this->setVideoNotFound(parent::PROCESS_TVMAZE, $row['id']); + $this->titleCache[] = $release['cleanname']; } - } //Processing failed, set the episode ID to the next processing group - $this->setVideoNotFound(parent::PROCESS_TVMAZE, $row['id']); + } else { + //Parsing failed, take it out of the queue for examination + $this->setVideoNotFound(parent::FAILED_PARSE, $row['id']); + $this->titleCache[] = $release['cleanname']; + } } } } @@ -197,7 +235,7 @@ class TVDB extends TV * * @param string $country * - * @return array|bool + * @return array|false */ protected function getShowInfo($cleanName, $country = '') { @@ -225,7 +263,7 @@ class TVDB extends TV if (is_array($response)) { foreach ($response as $show) { - if ($this->checkRequired($show, 'tvdbS')) { + if ($this->checkRequiredAttr($show, 'tvdbS')) { // Check for exact title match first and then terminate if found if (strtolower($show->name) === strtolower($cleanName)) { $highest = $show; @@ -254,7 +292,7 @@ class TVDB extends TV } } if (isset($highest)) { - $return = $this->formatShowArr($highest); + $return = $this->formatShowInfo($highest); } } @@ -296,7 +334,7 @@ class TVDB extends TV * @param string $airdate * @param integer $videoId * - * @return array|bool + * @return array|false */ protected function getEpisodeInfo($tvdbid, $season, $episode, $airdate = '', $videoId = 0) { @@ -331,13 +369,13 @@ class TVDB extends TV sleep(1); if (is_object($response)) { - if ($this->checkRequired($response, 'tvdbE')) { - $return = $this->formatEpisodeArr($response); + if ($this->checkRequiredAttr($response, 'tvdbE')) { + $return = $this->formatEpisodeInfo($response); } } else if (is_array($response) && isset($response['episodes']) && $videoId > 0) { foreach ($response['episodes'] as $singleEpisode) { - if ($this->checkRequired($singleEpisode, 'tvdbE')) { - $this->addEpisode($videoId, $this->formatEpisodeArr($singleEpisode)); + if ($this->checkRequiredAttr($singleEpisode, 'tvdbE')) { + $this->addEpisode($videoId, $this->formatEpisodeInfo($singleEpisode)); } } } @@ -353,7 +391,7 @@ class TVDB extends TV * * @return array */ - private function formatShowArr($show) + protected function formatShowInfo($show) { preg_match('/tt(?P\d{6,7})$/i', $show->imdbId, $imdb); @@ -361,7 +399,7 @@ class TVDB extends TV 'type' => (int)parent::TYPE_TV, 'title' => (string)$show->name, 'summary' => (string)$show->overview, - 'started' => (string)$show->firstAired->format($this->timeFormat), + 'started' => (string)$show->firstAired, 'publisher' => (string)$show->network, 'source' => (int)parent::SOURCE_TVDB, 'imdb' => (int)(isset($imdb['imdbid']) ? $imdb['imdbid'] : 0), @@ -382,14 +420,14 @@ class TVDB extends TV * * @return array */ - private function formatEpisodeArr($episode) + protected function formatEpisodeInfo($episode) { return [ 'title' => (string)$episode->name, 'series' => (int)$episode->season, 'episode' => (int)$episode->number, 'se_complete' => (string)'S' . sprintf('%02d', $episode->season) . 'E' . sprintf('%02d', $episode->number), - 'firstaired' => (string)$episode->firstAired->format($this->timeFormat), + 'firstaired' => (string)$episode->firstAired, 'summary' => (string)$episode->overview ]; } diff --git a/newznab/processing/tv/TVMaze.php b/newznab/processing/tv/TVMaze.php index b05b2e879..1520d5031 100644 --- a/newznab/processing/tv/TVMaze.php +++ b/newznab/processing/tv/TVMaze.php @@ -52,17 +52,17 @@ class TVMaze extends TV } /** - * Main processing director function for TVMaze + * Main processing director function for scrapers * Calls work query function and initiates processing * - * @param $groupID - * @param $guidChar - * @param $processTV - * @param bool|false $local + * @param $groupID + * @param $guidChar + * @param $process + * @param bool $local */ - public function processTVMaze ($groupID, $guidChar, $processTV, $local = false) + public function processSite ($groupID, $guidChar, $process, $local = false) { - $res = $this->getTvReleases($groupID, $guidChar, $processTV, parent::PROCESS_TVMAZE); + $res = $this->getTvReleases($groupID, $guidChar, $process, parent::PROCESS_TVMAZE); $tvcount = $res->rowCount(); @@ -71,15 +71,28 @@ class TVMaze extends TV } if ($res instanceof \Traversable) { + + $this->titleCache = []; + foreach ($res as $row) { $this->posterUrl = ''; $tvmazeid = false; // Clean the show name for better match probability - $release = $this->parseShowInfo($row['searchname']); + $release = $this->parseInfo($row['searchname']); if (is_array($release) && $release['name'] != '') { + if (in_array($release['cleanname'], $this->titleCache)) { + if ($this->echooutput) { + echo $this->pdo->log->headerOver("Title: ") . + $this->pdo->log->warningOver('"' . $release['cleanname'] . '"') . + $this->pdo->log->header(" already failed lookup for this site. Skipping."); + } + $this->setVideoNotFound(parent::PROCESS_TMDB, $row['id']); + continue; + } + // Find the Video ID if it already exists by checking the title against stored TVMaze titles $videoId = $this->getByTitle($release['cleanname'], parent::TYPE_TV, parent::SOURCE_TVMAZE); @@ -166,10 +179,21 @@ class TVMaze extends TV echo $this->pdo->log->primary("Found TVMaze Match!"); } continue; + } else { + //Processing failed, set the episode ID to the next processing group + $this->setVideoNotFound(parent::PROCESS_TMDB, $row['id']); + $this->titleCache[] = $release['cleanname']; } + } else { + //Processing failed, set the episode ID to the next processing group + $this->setVideoNotFound(parent::PROCESS_TMDB, $row['id']); + $this->titleCache[] = $release['cleanname']; } - } //Processing failed, set the episode ID to the next processing group - $this->setVideoNotFound(parent::PROCESS_TMDB, $row['id']); + } else{ + //Processing failed, set the episode ID to the next processing group + $this->setVideoNotFound(parent::PROCESS_TMDB, $row['id']); + $this->titleCache[] = $release['cleanname']; + } } } } @@ -181,7 +205,7 @@ class TVMaze extends TV * @param $site * @param $siteId * - * @return array|bool + * @return array|false */ protected function getShowInfoBySiteID($site, $siteId) { @@ -193,7 +217,7 @@ class TVMaze extends TV sleep(1); if (is_array($response)) { - $return = $this->formatShowArr($response); + $return = $this->formatShowInfo($response); } return $return; } @@ -204,7 +228,7 @@ class TVMaze extends TV * * @param $cleanName * - * @return array|bool + * @return array|false */ protected function getShowInfo($cleanName) { @@ -233,18 +257,18 @@ class TVMaze extends TV } /** - * @param $showArr + * @param $shows * @param $cleanName * * @return array|bool */ - private function matchShowInfo($showArr, $cleanName) + private function matchShowInfo($shows, $cleanName) { $return = false; $highestMatch = 0; - foreach ($showArr AS $show) { - if ($this->checkRequired($show, 'tvmazeS')) { + foreach ($shows AS $show) { + if ($this->checkRequiredAttr($show, 'tvmazeS')) { // Check for exact title match first and then terminate if found if (strtolower($show->name) === strtolower($cleanName)) { $highest = $show; @@ -273,7 +297,7 @@ class TVMaze extends TV } } if (isset($highest)) { - $return = $this->formatShowArr($highest); + $return = $this->formatShowInfo($highest); } return $return; } @@ -309,7 +333,7 @@ class TVMaze extends TV * @param string $airdate * @param integer $videoId * - * @return array|bool + * @return array|false */ protected function getEpisodeInfo($tvmazeid, $season, $episode, $airdate = '', $videoId = 0) { @@ -327,19 +351,19 @@ class TVMaze extends TV //Handle Single Episode Lookups if (is_object($response)) { - if ($this->checkRequired($response, 'tvmazeE')) { - $return = $this->formatEpisodeArr($response); + if ($this->checkRequiredAttr($response, 'tvmazeE')) { + $return = $this->formatEpisodeInfo($response); } } else if (is_array($response)) { //Handle new show/all episodes and airdate lookups foreach ($response as $singleEpisode) { - if ($this->checkRequired($singleEpisode, 'tvmazeE')) { + if ($this->checkRequiredAttr($singleEpisode, 'tvmazeE')) { // If this is an airdate lookup and it matches the airdate, set a return if ($airdate !== '' && $airdate == $singleEpisode->airdate) { - $return = $this->formatEpisodeArr($singleEpisode); + $return = $this->formatEpisodeInfo($singleEpisode); } else { // Insert the episode - $this->addEpisode($videoId, $this->formatEpisodeArr($singleEpisode)); + $this->addEpisode($videoId, $this->formatEpisodeInfo($singleEpisode)); } } } @@ -356,7 +380,7 @@ class TVMaze extends TV * * @return array */ - private function formatShowArr($show) + protected function formatShowInfo($show) { $this->posterUrl = (string)(isset($show->mediumImage) ? $show->mediumImage : ''); @@ -386,7 +410,7 @@ class TVMaze extends TV * * @return array */ - private function formatEpisodeArr($episode) + protected function formatEpisodeInfo($episode) { return [ 'title' => (string)$episode->name, diff --git a/newznab/processing/tv/TraktTv.php b/newznab/processing/tv/TraktTv.php index a7acc5384..44b9c6105 100644 --- a/newznab/processing/tv/TraktTv.php +++ b/newznab/processing/tv/TraktTv.php @@ -2,7 +2,6 @@ namespace newznab\processing\tv; use newznab\libraries\TraktAPI; -use newznab\ReleaseImage; /** * Class TraktTv @@ -11,8 +10,6 @@ use newznab\ReleaseImage; */ class TraktTv extends TV { - const MATCH_PROBABILITY = 75; - /** * Client for Trakt API * @@ -20,21 +17,6 @@ class TraktTv extends TV */ public $client; - /** - * @string DateTimeZone Object - UTC - */ - private $timeZone; - - /** - * @string MySQL DATETIME Format - */ - private $timeFormat; - - /** - * @var string The URL for the image for poster - */ - private $posterUrl; - /** * Construct. Set up API key. * @@ -45,133 +27,21 @@ class TraktTv extends TV public function __construct(array $options = []) { parent::__construct($options); - $this->client = new TraktAPI(['clientId' => $this->pdo->getSetting('trakttvclientkey')]); - $this->timeZone = new \DateTimeZone('UTC'); - $this->timeFormat = 'Y-m-d H:i:s'; + $this->client = new TraktAPI(['clientID' => $this->pdo->getSetting('trakttvclientkey')]); } /** - * Main processing director function for Trakt + * Main processing director function for scrapers * Calls work query function and initiates processing * - * @param $groupID - * @param $guidChar - * @param $processTV - * @param bool|false $local + * @param $groupID + * @param $guidChar + * @param $process + * @param bool $local */ - public function processTrakt($groupID, $guidChar, $processTV, $local = false) + public function processSite($groupID, $guidChar, $process, $local = false) { - $res = $this->getTvReleases($groupID, $guidChar, $processTV, parent::PROCESS_TRAKT); - - $tvcount = $res->rowCount(); - - if ($this->echooutput && $tvcount > 0) { - echo $this->pdo->log->header("Processing TRAKT lookup for " . number_format($tvcount) . " release(s)."); - } - - if ($res instanceof \Traversable) { - foreach ($res as $row) { - - $this->posterUrl = ''; - $traktid = false; - - // Clean the show name for better match probability - $release = $this->parseShowInfo($row['searchname']); - - if (is_array($release) && $release['name'] != '') { - - // Find the Video ID if it already exists by checking the title against stored TMDB titles - $videoId = $this->getByTitle($release['cleanname'], parent::TYPE_TV, parent::SOURCE_TRAKT); - - // Force local lookup only - if ($local == true) { - $lookupSetting = false; - } else { - $lookupSetting = true; - } - - // If lookups are allowed lets try to get it. - if ($videoId === false && $lookupSetting) { - if ($this->echooutput) { - echo $this->pdo->log->primaryOver("Checking TRAKT for previously failed title: ") . - $this->pdo->log->headerOver($release['cleanname']) . - $this->pdo->log->primary("."); - } - - // Get the show from TRAKT - $traktShow = $this->getShowInfo((string)$release['cleanname']); - - if (is_array($traktShow)) { - // Check if we have the TVDB ID already, if we do use that Video ID - $dupeCheck = $this->getVideoIDFromSiteID('tvdb', $traktShow['tvdb']); - if ($dupeCheck === false) { - $videoId = $this->add($traktShow); - $traktid = $traktShow['trakt']; - } else { - $videoId = $dupeCheck; - // Update any missing fields and add site IDs - $this->update($videoId, $traktShow); - $traktid = $this->getSiteIDFromVideoID('trakt', $videoId); - } - } - } else { - if ($this->echooutput) { - echo $this->pdo->log->primaryOver("Found local TRAKT match for: ") . - $this->pdo->log->headerOver($release['cleanname']) . - $this->pdo->log->primary(". Attempting episode lookup!"); - } - $traktid = $this->getSiteIDFromVideoID('trakt', $videoId); - } - - if (is_numeric($videoId) && $videoId > 0 && is_numeric($traktid) && $traktid > 0) { - // Now that we have valid video and trakt ids, try to get the poster - $this->getPoster($videoId, $traktid); - - $seasonNo = preg_replace('/^S0*/i', '', $release['season']); - $episodeNo = preg_replace('/^E0*/i', '', $release['episode']); - - if ($episodeNo === 'all') { - // Set the video ID and leave episode 0 - $this->setVideoIdFound($videoId, $row['id'], 0); - echo $this->pdo->log->primary("Found TRAKT Match for Full Season!"); - continue; - } - - // Download all episodes if new show to reduce API usage - if ($this->countEpsByVideoID($videoId) === false) { - $this->getEpisodeInfo($traktid, -1, -1, '', $videoId); - } - - // Check if we have the episode for this video ID - $episode = $this->getBySeasonEp($videoId, $seasonNo, $episodeNo, $release['airdate']); - - if ($episode === false) { - // Send the request for the episode to TRAKT - $traktEpisode = $this->getEpisodeInfo( - $traktid, - $seasonNo, - $episodeNo, - $release['airdate'] - ); - - if ($traktEpisode) { - $episode = $this->addEpisode($videoId, $traktEpisode); - } - } - - if ($episode !== false && is_numeric($episode) && $episode > 0) { - // Mark the releases video and episode IDs - $this->setVideoIdFound($videoId, $row['id'], $episode); - if ($this->echooutput) { - echo $this->pdo->log->primary("Found TRAKT Match!"); - } - continue; - } - } - } //Processing failed, set the episode ID to the next processing group - $this->setVideoNotFound(parent::PROCESS_IMDB, $row['id']); - } - } + ; } /** @@ -188,138 +58,47 @@ class TraktTv extends TV } /** - * Gets the specific episode info for the parsed release after match - * Returns a formatted array of episode data or false if no match + * Retrieve info of TV episode from site using its API. * - * @param integer $traktid - * @param integer $season + * @param integer $siteId + * @param integer $series * @param integer $episode - * @param string $airdate - * @param integer $videoId * - * @return array|bool + * @return array|false False on failure, an array of information fields otherwise. */ - protected function getEpisodeInfo($traktid, $season, $episode, $airdate = '', $videoId = 0) + public function getEpisodeInfo($siteId, $series, $episode) { - $return = $response = false; - - if ($videoId > 0) { - try { - $response = $this->client->showSummary($traktid); - } catch (\Exception $error) { - } - } else { - try { - $response = $this->client->episodeSummary($traktid, $season, $episode); - } catch (\Exception $error) { - } - } - - sleep(1); - - if (is_object($response)) { - if ($this->checkRequired($response, 'traktE')) { - $return = $this->formatEpisodeArr($response); - } - } else if (is_array($response) && $videoId > 0) { - if ($this->checkRequired($response, 'traktE')) { - $this->addEpisode($videoId, $this->formatEpisodeArr($response)); - } - } - - return $return; + ; } public function getMovieInfo() { - return false; + ; } /** - * Retrieves the poster art for the processed show + * Retrieve poster image for TV episode from site using its API. * - * @param int $videoId -- the local Video ID - * @param int $showId -- the TRAKT ID + * @param integer $videoId ID from videos table. + * @param integer $siteId ID that this site uses for the programme. * * @return null */ - protected function getPoster($videoId, $showId) + public function getPoster($videoId, $siteId) { - $ri = new ReleaseImage($this->pdo); - - $poster = $this->client->showSummary($showId, 'images'); - - // Try to get the Poster - $hascover = $ri->saveImage($videoId, $poster['images']['poster']['thumb'], $this->imgSavePath, '', ''); - - // Couldn't get poster, try fan art instead - if ($hascover !== 1) { - $hascover = $ri->saveImage($videoId, $poster['images']['fanart']['thumb'], $this->imgSavePath, '', ''); - } - // Mark it retrieved if we saved an image - if ($hascover == 1) { - $this->setCoverFound($videoId); - } + ; } /** - * Calls the API to perform initial show name match to TRAKT title - * Returns a formatted array of show data or false if no match + * Retrieve info of TV programme from site using it's API. * - * @param string $cleanName + * @param string $name Title of programme to look up. Usually a cleaned up version from releases table. * - * @param string $country - * - * @return array|bool + * @return array|false False on failure, an array of information fields otherwise. */ - protected function getShowInfo($cleanName, $country = '') + public function getShowInfo($name) { - $return = $response = false; - $highestMatch = 0; - try { - $response = (array)$this->client->showSummary($cleanName, 'full'); - } catch (\Exception $error) { - - } - - sleep(1); - - if (is_array($response)) { - foreach ($response as $show) { - if ($this->checkRequired($show, 'traktS')) { - // Check for exact title match first and then terminate if found - if ($show->name === $cleanName) { - $highest = $show; - break; - } - - // Check each show title for similarity and then find the highest similar value - $matchPercent = $this->checkMatch($show->name, $cleanName, self::MATCH_PROBABILITY); - - // If new match has a higher percentage, set as new matched title - if ($matchPercent > $highestMatch) { - $highestMatch = $matchPercent; - $highest = $show; - } - - // Check for show aliases and try match those too - if (!empty($show->aliasNames)) { - foreach ($show->aliasNames as $key => $name) { - $matchPercent = $this->CheckMatch($name, $cleanName, $matchPercent); - if ($matchPercent > $highestMatch) { - $highestMatch = $matchPercent; - $highest = $show; - } - } - } - } - } - if (isset($highest)) { - $return = $this->formatShowArr($highest); - } - } - - return $return; + ; } /** @@ -330,26 +109,9 @@ class TraktTv extends TV * * @return array */ - private function formatShowArr($show) + public function formatShowInfo($show) { - $show->firstAired->setTimezone($this->timeZone); - preg_match('/tt(?P\d{6,7})$/i', $show->ids->imdb, $imdb); - - return [ - 'type' => (int)parent::TYPE_TV, - 'title' => (string)$show->title, - 'summary' => (string)$show->overview, - 'started' => (string)$show->first_aired->format($this->timeFormat), - 'publisher' => (string)$show->network, - 'source' => (int)parent::SOURCE_TRAKT, - 'imdb' => (int)(isset($show->ids->imdb) ? $show->ids->imdb : 0), - 'tvdb' => 0, - 'trakt' => (int)$show->ids->trakt, - 'tvrage' => (int)(isset($show->ids->tvrage) ? $show->ids->tvrage : 0), - 'tvmaze' => 0, - 'tmdb' => (int)(isset($show->ids->tmdb) ? $show->ids->tmdb : 0), - 'aliases' => (!empty($show->aliasNames) ? (array)$show->aliasNames : '') - ]; + ; } /** @@ -360,17 +122,8 @@ class TraktTv extends TV * * @return array */ - private function formatEpisodeArr($episode) + public function formatEpisodeInfo($episode) { - $episode->firstAired->setTimezone($this->timeZone); - - return [ - 'title' => (string)$episode->title, - 'series' => (int)$episode->season, - 'episode' => (int)$episode->number, - 'se_complete' => (string)'S' . sprintf('%02d', $episode->season) . 'E' . sprintf('%02d', $episode->number), - 'firstaired' => (string)$episode->first_aired->format($this->timeFormat), - 'summary' => (string)$episode->overview - ]; + ; } } diff --git a/newznab/processing/tv/TvRage.php b/newznab/processing/tv/TvRage.php index c3e117cfa..c150cb8a8 100644 --- a/newznab/processing/tv/TvRage.php +++ b/newznab/processing/tv/TvRage.php @@ -2,6 +2,7 @@ namespace newznab\processing\tv; use newznab\utility\Utility; +use newznab\utility\Country; use newznab\ReleaseImage; /** @@ -74,14 +75,15 @@ class TvRage extends TV } /** - * Main function to begin TvRage processing + * Main processing director function for scrapers + * Calls work query function and initiates processing * - * @param string $groupID - * @param string $guidChar - * @param int $lookupSetting - * @param bool|false $local + * @param $groupID + * @param $guidChar + * @param $process + * @param bool $local */ - public function processTvRage($groupID = '', $guidChar = '', $lookupSetting = 1, $local = false) + public function processSite($groupID = '', $guidChar = '', $process, $local = false) { $res = $this->getTvReleases($groupID, $guidChar, $local, parent::PROCESS_TVRAGE); @@ -94,17 +96,17 @@ class TvRage extends TV if ($res instanceof \Traversable) { foreach ($res as $arr) { $this->rageId = $this->rageId = false; - $show = $this->parseShowInfo($arr['searchname']); + $show = $this->parseInfo($arr['searchname']); if (is_array($show) && $show['name'] != '') { // Find the Video ID if it already exists by checking the title. $this->videoId = $this->getByTitle($show['cleanname'], parent::TYPE_TV); // Force local lookup only if ($local == true) { - $lookupSetting = false; + $process = false; } - if ($this->videoId === false && $lookupSetting) { + if ($this->videoId === false && $process) { // If it doesnt exist locally and lookups are allowed lets try to get it. if ($this->echooutput) { echo $this->pdo->log->primaryOver("Video ID for ") . @@ -205,7 +207,7 @@ class TvRage extends TV $country = ''; if (isset($tvrShow['country']) && !empty($tvrShow['country'])) { - $country = $this->countryCode($tvrShow['country']); + $country = Country::countryCode($tvrShow['country'], $this->pdo); } $rInfo = $this->getRageInfoFromPage($rageid); @@ -293,7 +295,7 @@ class TvRage extends TV $result = ['showid' => $rageid]; $result['country'] = (isset($arrXml['origin_country'])) ? $arrXml['origin_country'] : ''; $result['firstaired'] = (isset($arrXml['startdate'])) ? date('m-d-Y', strtotime($arrXml['startdate'])) : ''; - $result = $this->countryCode($result); + $result = Country::countryCode($result, $this->pdo); } } return $result; @@ -408,7 +410,7 @@ class TvRage extends TV } } } - return $this->formatShowArr($matchedTitle); + return $this->formatShowInfo($matchedTitle); } /** @@ -419,7 +421,7 @@ class TvRage extends TV * * @return array */ - private function formatShowArr($show) + protected function formatShowInfo($show) { return [ 'type' => (int)parent::TYPE_TV, @@ -439,4 +441,17 @@ class TvRage extends TV 'tvr' => $show ]; } + + /** + * Assigns API episode response values to a formatted array for insertion + * Returns the formatted array + * + * @param $episode + * + * @return array + */ + protected function formatEpisodeInfo($episode) + { + return false; + } } diff --git a/newznab/utility/Country.php b/newznab/utility/Country.php new file mode 100644 index 000000000..1fee67cb2 --- /dev/null +++ b/newznab/utility/Country.php @@ -0,0 +1,59 @@ +. + * @author ruhllatio + * @copyright 2015 nZEDb + */ +namespace newznab\utility; + +use newznab\db\Settings; + +/** + * Class Country + * + * @package newznab\utility + */ +Class Country +{ + /** + * Get a country code for a country name. + * + * @param string $country + * + * @param Settings $pdo + * + * @return mixed + */ + public static function countryCode($country, $pdo) + { + $pdo = ($pdo instanceof Settings ? $pdo : new Settings()); + if (!is_array($country) && strlen($country) > 2) { + $code = $pdo->queryOneRow( + sprintf(' + SELECT id + FROM countries + WHERE country = %s', + $pdo->escapeString($country) + ) + ); + if (isset($code['id'])) { + return $code['id']; + } + } + return ''; + } +} \ No newline at end of file diff --git a/newznab/utility/Utility.php b/newznab/utility/Utility.php index 5c9ffdf0d..e6566d811 100644 --- a/newznab/utility/Utility.php +++ b/newznab/utility/Utility.php @@ -854,4 +854,58 @@ class Utility return $data; } + /** + * This function turns a roman numeral into an integer + * + * @param string $string + * + * @return int $e + */ + public static function convertRomanToInt($string) { + switch (strtolower($string)) { + case 'i': $e = 1; + break; + case 'ii': $e = 2; + break; + case 'iii': $e = 3; + break; + case 'iv': $e = 4; + break; + case 'v': $e = 5; + break; + case 'vi': $e = 6; + break; + case 'vii': $e = 7; + break; + case 'viii': $e = 8; + break; + case 'ix': $e = 9; + break; + case 'x': $e = 10; + break; + case 'xi': $e = 11; + break; + case 'xii': $e = 12; + break; + case 'xiii': $e = 13; + break; + case 'xiv': $e = 14; + break; + case 'xv': $e = 15; + break; + case 'xvi': $e = 16; + break; + case 'xvii': $e = 17; + break; + case 'xviii': $e = 18; + break; + case 'xix': $e = 19; + break; + case 'xx': $e = 20; + break; + default: + $e = 0; + } + return $e; + } } diff --git a/resources/db/patches/mysql/+1~collection_regex.sql b/resources/db/patches/mysql/+1~collection_regex.sql new file mode 100644 index 000000000..fa6ecfce7 --- /dev/null +++ b/resources/db/patches/mysql/+1~collection_regex.sql @@ -0,0 +1,9 @@ +REPLACE INTO collection_regexes (id, group_regex, regex, status, description, ordinal) +VALUES ( + 588, + '^alt\\.binaries\\.sounds\\.flac$', + '/^("|#34;)(?P.+?)(\\.part\\d*|\\.rar)?(\\.vol.+ \\(\\d+\\/\\d+\\) "|\\.[A-Za-z0-9]{2,4}("|#34;))[-_ ]{0,3}\\[\\d+\\/(?P\\d+\\]).+www\\.EliteNZB\\.net.+[-_ ]{0,3}yEnc$/i', + 1, + '"Jinsi_12187_v807.par2" [01/13] - The Elite Team Presents www.EliteNZB.net, Powered by 4UX.NL, Only The Best 4 You!!!! yEnc', + 20 +) \ No newline at end of file diff --git a/resources/db/patches/mysql/+2~videos_aliases.sql b/resources/db/patches/mysql/+2~videos_aliases.sql new file mode 100644 index 000000000..80eec65e9 --- /dev/null +++ b/resources/db/patches/mysql/+2~videos_aliases.sql @@ -0,0 +1,2 @@ +#Rename the videos_akas table to videos_aliases +RENAME TABLE videos_akas TO videos_aliases; \ No newline at end of file diff --git a/www/admin/show-edit.php b/www/admin/show-edit.php index 86c0fc956..69879656d 100755 --- a/www/admin/show-edit.php +++ b/www/admin/show-edit.php @@ -10,28 +10,15 @@ $video = new Videos(['Settings' => $page->settings]); switch ((isset($_REQUEST['action']) ? $_REQUEST['action'] : 'view')) { case 'submit': - $tv->update( - $_POST["id"], - [ - 'title' => $_POST["title"], - 'summary' => $_POST["summary"], - 'publisher' => $_POST["publisher"], - 'tvdb' => $_POST["tvdb"], - 'tvmaze' => $_POST["tvmaze"], - 'tmdb' => $_POST["tmdb"], - 'trakt' => $_POST["trakt"], - 'imdb' => $_POST["imdb"], - 'tvrage' => $_POST["tvrage"], - 'country' => $_POST['countries_id'] - ] - ); + //TODO: Use a function that allows overwrites + //$tv->update($_POST["id"], $_POST["title"],$_POST["summary"], $_POST['countries_id']); if (isset($_POST['from']) && !empty($_POST['from'])) { - header("Location: " . $_POST['from']); + header("Location:" . $_POST['from']); exit; } - header("Location: " . WWW_TOP . "/show-list.php"); + header("Location:" . WWW_TOP . "/show-list.php"); break; case 'view': diff --git a/www/pages/smartyTV.php b/www/pages/smartyTV.php index 533d34978..bf6847ddc 100644 --- a/www/pages/smartyTV.php +++ b/www/pages/smartyTV.php @@ -24,8 +24,23 @@ use newznab\processing\tv\TV; class smartyTV extends TV { + /** + * Main processing director function for scrapers + * Calls work query function and initiates processing + * + * @param $groupID + * @param $guidChar + * @param $process + * @param bool $local + */ + protected function processSite($groupID, $guidChar, $process, $local = false) + { + ; + } + protected function getBanner($videoID, $siteId) { + ; } /** @@ -39,6 +54,7 @@ class smartyTV extends TV */ protected function getEpisodeInfo($siteId, $series, $episode) { + ; } /** @@ -51,6 +67,7 @@ class smartyTV extends TV */ protected function getPoster($videoId, $siteId) { + ; } /** @@ -62,6 +79,33 @@ class smartyTV extends TV */ protected function getShowInfo($name) { + ; + } + + /** + * Assigns API show response values to a formatted array for insertion + * Returns the formatted array + * + * @param $show + * + * @return array + */ + protected function formatShowInfo($show) + { + ; + } + + /** + * Assigns API episode response values to a formatted array for insertion + * Returns the formatted array + * + * @param $episode + * + * @return array + */ + protected function formatEpisodeInfo($episode) + { + ; } } diff --git a/www/themes_shared/templates/admin/show-edit.tpl b/www/themes_shared/templates/admin/show-edit.tpl index dda2a3cd9..586f2c96c 100755 --- a/www/themes_shared/templates/admin/show-edit.tpl +++ b/www/themes_shared/templates/admin/show-edit.tpl @@ -1,67 +1,67 @@

{$page->title}

- + - - - - + + + + @@ -74,22 +74,22 @@
- - -
The numeric TV Show Id.
+ + +
The numeric Video Id. Changing this is not recommended.
- - + +
The numeric TVDB Show Id.
- - + +
The numeric TVMaze Show Id.
- - -
The numeric The MovieDB Show Id.
+ + +
The numeric TMDB Show Id.
- - + +
The numeric Trakt Show Id.
- - -
The numeric Imdb Show Id.
-
- - + +
The numeric TvRage Show Id.
+ + +
The numeric IMDB Show Id.
+
- +
The title of the TV show.
- +
- +
The countries_id for the TV show.
- +
-
+ \ No newline at end of file diff --git a/www/themes_shared/templates/admin/show-list.tpl b/www/themes_shared/templates/admin/show-list.tpl index b38ec3ce5..3508181f8 100755 --- a/www/themes_shared/templates/admin/show-list.tpl +++ b/www/themes_shared/templates/admin/show-list.tpl @@ -27,9 +27,6 @@ {if $tvshow.source == 1}tvdb {elseif $tvshow.source == 2}tvmaze {elseif $tvshow.source == 3}tmdb - {elseif $tvshow.source == 4}trakt - {elseif $tvshow.source == 5}imdb - {elseif $tvshow.source == 6}tvrage {/if} delete | remove @@ -38,4 +35,4 @@ {else}

No TV Shows available.

-{/if} +{/if} \ No newline at end of file