From a95c030885f86c60c22e2fa055f4464593273051 Mon Sep 17 00:00:00 2001 From: Dean Gardiner Date: Fri, 6 Sep 2013 13:29:25 +1200 Subject: [PATCH] Fix for discovering the cat_ids structure when the 'ids' are of str type. --- couchpotato/core/media/show/searcher/main.py | 2 +- couchpotato/core/providers/base.py | 16 +++++++++++++++- couchpotato/core/providers/torrent/iptorrents/main.py | 4 ++-- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/couchpotato/core/media/show/searcher/main.py b/couchpotato/core/media/show/searcher/main.py index 604752b..8d0f0ae 100644 --- a/couchpotato/core/media/show/searcher/main.py +++ b/couchpotato/core/media/show/searcher/main.py @@ -75,7 +75,7 @@ class ShowSearcher(Plugin): return show, season, episode = self._lookupMedia(media) - if not show or not season: + if show is None or season is None: log.error('Unable to find show or season library in database, missing required data for searching') return diff --git a/couchpotato/core/providers/base.py b/couchpotato/core/providers/base.py index d652b38..57b4fea 100644 --- a/couchpotato/core/providers/base.py +++ b/couchpotato/core/providers/base.py @@ -102,6 +102,7 @@ class YarrProvider(Provider): type = 'movie' cat_ids = {} + cat_ids_structure = None cat_backup_id = None sizeGb = ['gb', 'gib'] @@ -246,11 +247,24 @@ class YarrProvider(Provider): return 0 + def _discoverCatIdStructure(self): + # Discover cat_ids structure (single or groups) + for group_name, group_cat_ids in self.cat_ids: + if len(group_cat_ids) > 0: + if type(group_cat_ids[0]) is tuple: + self.cat_ids_structure = 'groups' + if type(group_cat_ids[0]) is str: + self.cat_ids_structure = 'single' + def getCatId(self, identifier, media_type = 'movie'): cat_ids = self.cat_ids - if type(toIterable(cat_ids[0][0])[0]) is str: + if not self.cat_ids_structure: + self._discoverCatIdStructure() + + # If cat_ids is in a 'groups' structure, locate the media group + if self.cat_ids_structure == 'groups': for group_type, group_cat_ids in cat_ids: if media_type in toIterable(group_type): cat_ids = group_cat_ids diff --git a/couchpotato/core/providers/torrent/iptorrents/main.py b/couchpotato/core/providers/torrent/iptorrents/main.py index 3717375..42a8379 100644 --- a/couchpotato/core/providers/torrent/iptorrents/main.py +++ b/couchpotato/core/providers/torrent/iptorrents/main.py @@ -27,10 +27,10 @@ class IPTorrents(TorrentProvider): ([7], ['dvdrip', 'brrip']), ([6], ['dvdr']), ]), - (['season'], [ + ('season', [ ([65], ['hdtv', '480p', '720p', '1080p']), ]), - (['episode'], [ + ('episode', [ ([5], ['720p', '1080p']), ([78], ['480p']), ([4, 79], ['hdtv'])