From c176af43e6762dc201ce6458e5ed0887231e6fab Mon Sep 17 00:00:00 2001 From: DariusIII Date: Sat, 31 Oct 2015 22:08:26 +0100 Subject: [PATCH 1/2] Add first batch of changes for akas processing --- Changelog | 2 + newznab/processing/Videos.php | 263 ++++++++++++++++++ newznab/processing/tv/TV.php | 215 +------------- newznab/processing/tv/TVDB.php | 6 +- newznab/processing/tv/TVMaze.php | 6 +- newznab/processing/tv/TvRage.php | 9 +- resources/db/patches/mysql/+1~videos_akas.sql | 14 + 7 files changed, 305 insertions(+), 210 deletions(-) create mode 100644 resources/db/patches/mysql/+1~videos_akas.sql diff --git a/Changelog b/Changelog index 6ddbe8f39..5ba3cd8f6 100755 --- a/Changelog +++ b/Changelog @@ -1,3 +1,5 @@ +2015-10-31 DariusIII + Upd: Add first batch of changes for akas processing 2015-10-30 DariusIII Fix: ApiIO errors. Fix: Some of the problems created by moving TVMaze up in processing diff --git a/newznab/processing/Videos.php b/newznab/processing/Videos.php index 6896abad7..e513dd5c9 100644 --- a/newznab/processing/Videos.php +++ b/newznab/processing/Videos.php @@ -33,6 +33,7 @@ abstract class Videos const TYPE_TV = 0; // Type of video is a TV Programme/Show const TYPE_FILM = 1; // Type of video is a Film/Movie const TYPE_ANIME = 2; // Type of video is a Anime + /** * @var \newznab\db\Settings */ @@ -94,4 +95,266 @@ abstract class Videos } return false; } + + /** + * Attempt a local lookup via the title first by exact match and then by like. + * Returns a false for no match or the Video ID of the match. + * + * @param $title + * @param $type + * + * @return bool + */ + public function getByTitle($title, $type) + { + // Check if we already have an entry for this show. + $res = $this->getByTitleQuery($title, $type); + if (isset($res['id'])) { + return $res['id']; + } + + $title2 = str_replace(' and ', ' & ', $title); + if ($title != $title2) { + $res = $this->getByTitleQuery($title2, $type); + if (isset($res['id'])) { + return $res['id']; + } + $pieces = explode(' ', $title2); + $title4 = '%'; + foreach ($pieces as $piece) { + $title4 .= str_replace(["'", "!"], "", $piece) . '%'; + } + $res = $this->getByTitleLikeQuery($title4, $type); + if (isset($res['id'])) { + return $res['id']; + } + } + + // 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); + if (isset($res['id'])) { + return $res['id']; + } + $pieces = explode(' ', $title3); + $title4 = '%'; + foreach ($pieces as $piece) { + $title4 .= str_replace(["'", "!"], "", $piece) . '%'; + } + $res = $this->getByTitleLikeQuery($title4, $type); + if (isset($res['id'])) { + return $res['id']; + } + } + + // If there was not an exact title match, look for title with missing chars + // example release name :Zorro 1990, tvrage name Zorro (1990) + // Only search if the title contains more than one word to prevent incorrect matches + $pieces = explode(' ', $title); + if (count($pieces) > 1) { + $title4 = '%'; + foreach ($pieces as $piece) { + $title4 .= str_replace(["'", "!"], "", $piece) . '%'; + } + $res = $this->getByTitleLikeQuery($title4, $type); + if (isset($res['id'])) { + return $res['id']; + } + } + return false; + } + + /** + * Supplementary function for getByTitle that queries for exact match + * + * @param $title + * @param $type + * + * @return array|bool + */ + public function getByTitleQuery($title, $type) + { + $return = false; + if ($title) { + $return = $this->pdo->queryOneRow( + sprintf(" + SELECT v.id + FROM videos v + LEFT JOIN videos_akas va ON v.id = va.videos_id + WHERE (v.title = %1\$s OR va.title = %1\$s) + AND v.type = %d", + $this->pdo->escapeString($title), + $type + ) + ); + } + return $return; + } + + /** + * Supplementary function for getByTitle that queries for a like match + * + * @param $title + * @param $type + * + * @return array|bool + */ + public function getByTitleLikeQuery($title, $type) + { + $return = false; + $string = '"\'"'; + if ($title) { + $return = $this->pdo->queryOneRow( + sprintf(" + SELECT id + FROM videos + WHERE REPLACE(REPLACE(title, %s, ''), '!', '') %s + AND type = %d", + $string, + $this->pdo->likeString(rtrim($title, '%'), false, false), + $type + ) + ); + } + return $return; + } + + /** + * Inserts aliases for videos + * + * @param $videoId + * @param array $aliasArr + */ + public function addAliases($videoId, $aliasArr = array()) + { + if (is_array($aliasArr) && $videoId > 0) { + foreach ($aliasArr AS $alias) { + // Check if we have the AKA already + $check = $this->getAliases(0, $alias); + + if ($check === false) { + $this->pdo->queryInsert( + sprintf(' + INSERT IGNORE INTO videos_akas + (videos_id, title) + VALUES (%d, %s)', + $videoId, + $this->pdo->escapeString($alias) + ) + ); + } + } + } + } + + /** + * Retrieves all aliases for given VideoID or VideoID for a given alias + * + * @param int $videoId + * @param string $alias + * + * @return bool|\PDOStatement + */ + public function getAliases($videoId = 0, $alias = '') + { + $return = false; + $sql = ''; + + if ($videoId > 0) { + $sql = 'videos_id = ' . $videoId; + } elseif ($alias !== '') { + $sql = 'title = ' . $this->pdo->escapeString($alias); + } + + if ($sql !== '') { + $return = $this->pdo->queryDirect(' + SELECT * + FROM videos_akas + WHERE ' . $sql + ); + } + return $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/TV.php b/newznab/processing/tv/TV.php index 223bc3723..104904689 100644 --- a/newznab/processing/tv/TV.php +++ b/newznab/processing/tv/TV.php @@ -222,15 +222,17 @@ abstract class TV extends Videos } if ($videoId === false) { - $videoId = $this->getByTitleQuery($showArr['title']); + $videoId = $this->getByTitleQuery($showArr['title'], $showArr['type']); } if ($videoId === false) { + // Insert the Show $videoId = $this->pdo->queryInsert( sprintf(' INSERT INTO videos (type, title, countries_id, started, source, tvdb, trakt, tvrage, tvmaze, imdb, tmdb) - VALUES (0, %s, %s, %s, %d, %d, %d, %d, %d, %d, %d)', + 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']), @@ -243,6 +245,7 @@ abstract class TV extends Videos $showArr['tmdb'] ) ); + // Insert the supplementary show info $this->pdo->queryInsert( sprintf(" INSERT INTO tv_info (videos_id, summary, publisher) @@ -252,7 +255,12 @@ abstract class TV extends Videos $this->pdo->escapeString($showArr['publisher']) ) ); + // If we have AKAs\aliases, insert those as well + if (is_array($showArr['aliases'])) { + $this->addAliases($videoId, $showArr['aliases']); + } } else { + // If a local match was found, just update missing video info $this->update($videoId, $showArr); } return (int)$videoId; @@ -290,8 +298,6 @@ abstract class TV extends Videos return $episodeId; } - // If the video already exists, update the site specific column to collect its ID for that scrape - /** * Updates the show info with data from the supplied array * Only called when a duplicate show is found during insert @@ -345,6 +351,7 @@ abstract class TV extends Videos 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 WHERE v.id = %d", $id ) @@ -368,126 +375,6 @@ abstract class TV extends Videos ); } - /** - * Attempt a local lookup via the title first by exact match and then by like. - * Returns a false for no match or the Video ID of the match. - * - * @param $title - * - * @return bool - */ - public function getByTitle($title) - { - // Check if we already have an entry for this show. - $res = $this->getByTitleQuery($title); - if (isset($res['id'])) { - return $res['id']; - } - - $title2 = str_replace(' and ', ' & ', $title); - if ($title != $title2) { - $res = $this->getByTitleQuery($title2); - if (isset($res['id'])) { - return $res['id']; - } - $pieces = explode(' ', $title2); - $title4 = '%'; - foreach ($pieces as $piece) { - $title4 .= str_replace(["'", "!"], "", $piece) . '%'; - } - $res = $this->getByTitleLikeQuery($title4 . '%'); - if (isset($res['id'])) { - return $res['id']; - } - } - - // Some words are spelled correctly 2 ways - // example theatre and theater - $title3 = str_replace('er', 're', $title); - if ($title != $title3) { - $res = $this->getByTitleQuery($title3); - if (isset($res['id'])) { - return $res['id']; - } - $pieces = explode(' ', $title3); - $title4 = '%'; - foreach ($pieces as $piece) { - $title4 .= str_replace(["'", "!"], "", $piece) . '%'; - } - $res = $this->getByTitleLikeQuery($title4); - if (isset($res['id'])) { - return $res['id']; - } - } - - // If there was not an exact title match, look for title with missing chars - // example release name :Zorro 1990, tvrage name Zorro (1990) - // Only search if the title contains more than one word to prevent incorrect matches - $pieces = explode(' ', $title); - if (count($pieces) > 1) { - $title4 = '%'; - foreach ($pieces as $piece) { - $title4 .= str_replace(["'", "!"], "", $piece) . '%'; - } - $res = $this->getByTitleLikeQuery($title4); - if (isset($res['id'])) { - return $res['id']; - } - } - return false; - } - - /** - * Supplementary function for getByTitle that queries for exact match - * - * - * @param $title - * - * @return array|bool - */ - public function getByTitleQuery($title) - { - $return = false; - if ($title) { - $return = $this->pdo->queryOneRow( - sprintf(" - SELECT id - FROM videos - WHERE title = %s - AND type = 0", - $this->pdo->escapeString($title) - ) - ); - } - return $return; - } - - /** - * Supplementary function for getByTitle that queries for a like match - * - * @param $title - * - * @return array|bool - */ - public function getByTitleLikeQuery($title) - { - $return = false; - $string = '"\'"'; - if ($title) { - $return = $this->pdo->queryOneRow( - sprintf(" - SELECT id - FROM videos - WHERE REPLACE(REPLACE(title, %s, ''), '!', '') %s - AND type = 0", - $string, - $this->pdo->likeString(rtrim($title, '%'), false, false) - ) - ); - } - return $return; - } - /** * Get site ID from a Video ID and the site's respective column. * Returns the ID value or false if none found @@ -547,31 +434,6 @@ abstract class TV extends Videos return (isset($episodeArr['id']) ? $episodeArr['id'] : false); } - /** - * 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 = %1\$s', - $this->pdo->escapeString($country) - ) - ); - if (isset($code['id'])) { - return $code['id']; - } - } - return ''; - } - /** * Returns (true) if episodes for a given Video ID exist or don't (false) * @@ -783,61 +645,6 @@ abstract class TV extends Videos return false; } - /** - * This function turns a roman numeral into an integer - * - * @param string $string - * - * @return int $e - */ - private 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; - } - /** * Simple function that compares two strings of text * Returns percentage of similarity diff --git a/newznab/processing/tv/TVDB.php b/newznab/processing/tv/TVDB.php index e2f14b21c..cb660d61e 100644 --- a/newznab/processing/tv/TVDB.php +++ b/newznab/processing/tv/TVDB.php @@ -87,7 +87,7 @@ class TVDB extends TV if (is_array($release) && $release['name'] != '') { // Find the Video ID if it already exists by checking the title. - $videoId = $this->getByTitle($release['cleanname']); + $videoId = $this->getByTitle($release['cleanname'], parent::TYPE_TV); if ($videoId !== false) { $tvdbid = $this->getSiteByID('tvdb', $videoId); @@ -348,6 +348,7 @@ class TVDB extends TV preg_match('/tt(?P\d{6,7})$/i', $show->imdbId, $imdb); return [ + 'type' => (int)parent::TYPE_TV, 'title' => (string)$show->name, 'summary' => (string)$show->overview, 'started' => (string)$show->firstAired->format($this->timeFormat), @@ -358,7 +359,8 @@ class TVDB extends TV 'trakt' => 0, 'tvrage' => 0, 'tvmaze' => 0, - 'tmdb' => 0 + 'tmdb' => 0, + 'aliases' => (is_array($show->aliasNames) ? $show->aliasNames : '') ]; } diff --git a/newznab/processing/tv/TVMaze.php b/newznab/processing/tv/TVMaze.php index 261023cd6..b9bf438cf 100644 --- a/newznab/processing/tv/TVMaze.php +++ b/newznab/processing/tv/TVMaze.php @@ -81,7 +81,7 @@ class TVMaze extends TV if (is_array($release) && $release['name'] != '') { // Find the Video ID if it already exists by checking the title. - $videoId = $this->getByTitle($release['cleanname']); + $videoId = $this->getByTitle($release['cleanname'], parent::TYPE_TV); if ($videoId !== false) { $tvmazeid = $this->getSiteByID('tvmaze', $videoId); @@ -347,6 +347,7 @@ class TVMaze extends TV $this->posterUrl = (string)(isset($show->mediumImage) ? $show->mediumImage : ''); return [ + 'type' => (int)parent::TYPE_TV, 'title' => (string)$show->name, 'summary' => (string)$show->summary, 'started' => (string)$show->premiered, @@ -358,7 +359,8 @@ class TVMaze extends TV 'tvmaze' => (int)$show->id, 'trakt' => 0, 'tvrage' => (int)(isset($show->externalIDs['tvrage']) ? $show->externalIDs['tvrage'] : 0), - 'tmdb' => 0 + 'tmdb' => 0, + 'aliases' => (is_array($show->akas) ? $show->akas : '') ]; } diff --git a/newznab/processing/tv/TvRage.php b/newznab/processing/tv/TvRage.php index 6a89aa23d..061495a2a 100644 --- a/newznab/processing/tv/TvRage.php +++ b/newznab/processing/tv/TvRage.php @@ -97,7 +97,7 @@ class TvRage extends TV $show = $this->parseNameEpSeason($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']); + $this->videoId = $this->getByTitle($show['cleanname'], parent::TYPE_TV); // Force local lookup only if ($local == true) { @@ -215,6 +215,7 @@ class TvRage extends TV } $this->videoId = $this->add( [ + 'type' => parent::TYPE_TV, 'title' => $tvrShow['title'], 'column' => 'tvrage', 'siteid' => $rageid, @@ -228,7 +229,8 @@ class TvRage extends TV 'tvrageid' => $rageid, 'tvmazeid' => 0, 'imdbid' => 0, - 'tmdbid' => 0 + 'tmdbid' => 0, + 'aliases' => $tvrShow['aliases'] ] ); if (isset($rInfo['imgurl']) && !empty($rInfo['imgurl'])) { @@ -393,6 +395,7 @@ class TvRage extends TV // One aka. $matchPercent = $this->checkMatch($title, $show['akas']['aka'], self::MATCH_PROBABILITY); if ($matchPercent > $highestPercent) { + $show['akas']['aka'][] = $show['akas']['aka']; $matchedTitle = $show; $highestPercent = $matchPercent; } @@ -419,6 +422,7 @@ class TvRage extends TV private function formatShowArr($show) { return [ + 'type' => (int)parent::TYPE_TV, 'title' => (string)$show['name'], 'summary' => (string)'', 'started' => (string)date('Y-m-d', strtotime($show['started'])), @@ -431,6 +435,7 @@ class TvRage extends TV 'tvrage' => (int)$show['showid'], 'tvmaze' => 0, 'tmdb' => 0, + 'aliases' => (is_array($show['akas']['aka']) ? $show['akas']['aka'] : ''), 'tvr' => $show ]; } diff --git a/resources/db/patches/mysql/+1~videos_akas.sql b/resources/db/patches/mysql/+1~videos_akas.sql new file mode 100644 index 000000000..767672c7f --- /dev/null +++ b/resources/db/patches/mysql/+1~videos_akas.sql @@ -0,0 +1,14 @@ +# This patch creates the videos_akas table to store AKAs retrieved +# from scrape sources. This will keep a record of them for local +# lookup searches to speed up processing and prevent API hammering + +DROP TABLE IF EXISTS videos_akas; +CREATE TABLE videos_akas ( + videos_id MEDIUMINT(11) UNSIGNED NOT NULL COMMENT 'FK to videos.id of the parent title.', + title VARCHAR(180) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'AKA of the video.', + PRIMARY KEY (videos_id, title) +) + ENGINE = MyISAM + DEFAULT CHARSET = utf8 + COLLATE = utf8_unicode_ci + AUTO_INCREMENT = 100000; \ No newline at end of file From f309df2ac10c343f51db3e041e1007fc17600677 Mon Sep 17 00:00:00 2001 From: DariusIII Date: Sat, 31 Oct 2015 22:19:47 +0100 Subject: [PATCH 2/2] Add all available sources to tv view --- Changelog | 1 + .../charisma/templates/frontend/viewnzb.tpl | 8 +++++ .../templates/frontend/viewseries.tpl | 32 ++++++++++++------- .../templates/frontend/viewserieslist.tpl | 8 +++++ .../omicron/templates/frontend/viewnzb.tpl | 8 +++++ .../omicron/templates/frontend/viewseries.tpl | 32 ++++++++++++------- .../templates/frontend/viewserieslist.tpl | 8 +++++ 7 files changed, 73 insertions(+), 24 deletions(-) diff --git a/Changelog b/Changelog index 5ba3cd8f6..0f53961be 100755 --- a/Changelog +++ b/Changelog @@ -1,4 +1,5 @@ 2015-10-31 DariusIII + Upd: Add all sources that are avalable to series view Upd: Add first batch of changes for akas processing 2015-10-30 DariusIII Fix: ApiIO errors. diff --git a/www/themes/charisma/templates/frontend/viewnzb.tpl b/www/themes/charisma/templates/frontend/viewnzb.tpl index f5fad7af5..e6d892b6c 100644 --- a/www/themes/charisma/templates/frontend/viewnzb.tpl +++ b/www/themes/charisma/templates/frontend/viewnzb.tpl @@ -52,21 +52,29 @@ View all episodes {if $show.source == 1} + {if $show.tvdb > 0} TheTVDB + {/if} {elseif $show.source == 2} + {if $show.tvmaze > 0} TVMaze + {/if} {elseif $show.source == 3} + {if $show.trakt > 0} Trakt + {/if} {elseif $show.source == 6} + {if $show.tvrage > 0} TV Rage + {/if} {/if} {/if} {if $con && $con.url != ""}RSS for TV Show {if $show.source == 1} - TheTVDB + {if $show.tvdb > 0} + TheTVDB + {/if} {elseif $show.source == 2} - TVMaze + {if $show.tvmaze > 0} + TVMaze + {/if} {elseif $show.source == 3} - Trakt + {if $show.trakt > 0} + Trakt + {/if} {elseif $show.source == 6} - TV Rage + {if $show.tvrage > 0} + TV Rage + {/if} {/if}
diff --git a/www/themes/charisma/templates/frontend/viewserieslist.tpl b/www/themes/charisma/templates/frontend/viewserieslist.tpl index fb4428e62..37819bce4 100644 --- a/www/themes/charisma/templates/frontend/viewserieslist.tpl +++ b/www/themes/charisma/templates/frontend/viewserieslist.tpl @@ -59,13 +59,21 @@ Series
{if $s.id > 0} {if $s.source == 1} + {if $show.tvdb > 0} TVDB + {/if} {elseif $s.source == 2} + {if $show.tvmaze > 0} TVMaze + {/if} {elseif $s.source == 3} + {if $show.trakt > 0} Trakt + {/if} {elseif $s.source == 6} + {if $show.tvrage > 0} TVRage + {/if} {/if} {/if} diff --git a/www/themes/omicron/templates/frontend/viewnzb.tpl b/www/themes/omicron/templates/frontend/viewnzb.tpl index f5fad7af5..e6d892b6c 100644 --- a/www/themes/omicron/templates/frontend/viewnzb.tpl +++ b/www/themes/omicron/templates/frontend/viewnzb.tpl @@ -52,21 +52,29 @@ View all episodes {if $show.source == 1} + {if $show.tvdb > 0} TheTVDB + {/if} {elseif $show.source == 2} + {if $show.tvmaze > 0} TVMaze + {/if} {elseif $show.source == 3} + {if $show.trakt > 0} Trakt + {/if} {elseif $show.source == 6} + {if $show.tvrage > 0} TV Rage + {/if} {/if} {/if} {if $con && $con.url != ""}RSS for TV Show {if $show.source == 1} - TheTVDB + {if $show.tvdb > 0} + TheTVDB + {/if} {elseif $show.source == 2} - TVMaze + {if $show.tvmaze > 0} + TVMaze + {/if} {elseif $show.source == 3} - Trakt + {if $show.trakt > 0} + Trakt + {/if} {elseif $show.source == 6} - TV Rage + {if $show.tvrage > 0} + TV Rage + {/if} {/if}
diff --git a/www/themes/omicron/templates/frontend/viewserieslist.tpl b/www/themes/omicron/templates/frontend/viewserieslist.tpl index fb4428e62..37819bce4 100644 --- a/www/themes/omicron/templates/frontend/viewserieslist.tpl +++ b/www/themes/omicron/templates/frontend/viewserieslist.tpl @@ -59,13 +59,21 @@ Series
{if $s.id > 0} {if $s.source == 1} + {if $show.tvdb > 0} TVDB + {/if} {elseif $s.source == 2} + {if $show.tvmaze > 0} TVMaze + {/if} {elseif $s.source == 3} + {if $show.trakt > 0} Trakt + {/if} {elseif $s.source == 6} + {if $show.tvrage > 0} TVRage + {/if} {/if} {/if}