From dd58028ba66b1cf5c109672a1cfb157e104dc194 Mon Sep 17 00:00:00 2001 From: echel0n Date: Wed, 26 Mar 2014 19:01:53 -0700 Subject: [PATCH] Bugfix for indexerApi improperly returning list of indexers --- .../interfaces/default/home_massAddTable.tmpl | 2 +- sickbeard/helpers.py | 2 +- sickbeard/indexers/indexer_api.py | 7 ++++--- sickbeard/name_parser/parser.py | 2 +- sickbeard/postProcessor.py | 2 +- sickbeard/scene_exceptions.py | 2 +- sickbeard/showUpdater.py | 2 +- sickbeard/webserve.py | 17 +++++++++-------- 8 files changed, 19 insertions(+), 17 deletions(-) diff --git a/gui/slick/interfaces/default/home_massAddTable.tmpl b/gui/slick/interfaces/default/home_massAddTable.tmpl index 2359ed12..6de79abf 100644 --- a/gui/slick/interfaces/default/home_massAddTable.tmpl +++ b/gui/slick/interfaces/default/home_massAddTable.tmpl @@ -30,7 +30,7 @@ #end if diff --git a/sickbeard/helpers.py b/sickbeard/helpers.py index a151e93d..72005e5e 100644 --- a/sickbeard/helpers.py +++ b/sickbeard/helpers.py @@ -942,7 +942,7 @@ def get_show_by_name(name, showList, useIndexer=False): return show if useIndexer: - for indexer in sickbeard.indexerApi.indexers(): + for indexer in sickbeard.indexerApi().indexers: try: lINDEXER_API_PARMS = sickbeard.indexerApi(indexer).api_params.copy() lINDEXER_API_PARMS['custom_ui'] = classes.ShowListUI diff --git a/sickbeard/indexers/indexer_api.py b/sickbeard/indexers/indexer_api.py index 8d7ae2fa..559960d2 100644 --- a/sickbeard/indexers/indexer_api.py +++ b/sickbeard/indexers/indexer_api.py @@ -20,6 +20,7 @@ import sickbeard from indexer_config import initConfig, indexerConfig + class indexerApi(object): def __init__(self, indexerID=None): self.indexerID = indexerID @@ -43,7 +44,7 @@ class indexerApi(object): def api_params(self): if self.indexerID: if sickbeard.CACHE_DIR: - indexerConfig[self.indexerID]['api_params']['cache'] = os.path.join(sickbeard.CACHE_DIR, self.name) + indexerConfig[self.indexerID]['api_params']['cache'] = os.path.join(sickbeard.CACHE_DIR, self.name) return indexerConfig[self.indexerID]['api_params'] @property @@ -51,6 +52,6 @@ class indexerApi(object): if sickbeard.CACHE_DIR: return self.api_params['cache'] - @staticmethod - def indexers(): + @property + def indexers(self): return {k: v if k is 'id' else v['name'] for k, v in indexerConfig.items()} \ No newline at end of file diff --git a/sickbeard/name_parser/parser.py b/sickbeard/name_parser/parser.py index e8ac18d5..aefd2b26 100644 --- a/sickbeard/name_parser/parser.py +++ b/sickbeard/name_parser/parser.py @@ -284,7 +284,7 @@ class NameParser(object): # see if we can find the name with a TVDB lookup if check_indexer: for cur_name in name_list: - for indexer in sickbeard.indexerApi.indexers(): + for indexer in sickbeard.indexerApi().indexers: try: lINDEXER_API_PARMS = sickbeard.indexerApi(indexer).api_params.copy() diff --git a/sickbeard/postProcessor.py b/sickbeard/postProcessor.py index f84e2fc2..6e290721 100644 --- a/sickbeard/postProcessor.py +++ b/sickbeard/postProcessor.py @@ -830,7 +830,7 @@ class PostProcessor(object): # try to find the file info indexer_id = season = episodes = None - for indexer in sickbeard.indexerApi.indexers(): + for indexer in sickbeard.indexerApi().indexers: self.indexer = int(indexer) self._log(u"Searching " + sickbeard.indexerApi(self.indexer).name + ", trying to auto-detect Indexer for " diff --git a/sickbeard/scene_exceptions.py b/sickbeard/scene_exceptions.py index 16d1af7c..cc17e345 100644 --- a/sickbeard/scene_exceptions.py +++ b/sickbeard/scene_exceptions.py @@ -73,7 +73,7 @@ def retrieve_exceptions(): # exceptions are stored on github pages - for indexer in sickbeard.indexerApi.indexers(): + for indexer in sickbeard.indexerApi().indexers: logger.log(u"Checking for scene exception updates for " + sickbeard.indexerApi(indexer).name + "") url = sickbeard.indexerApi(indexer).config['scene_url'] diff --git a/sickbeard/showUpdater.py b/sickbeard/showUpdater.py index 7207d439..34f944cc 100644 --- a/sickbeard/showUpdater.py +++ b/sickbeard/showUpdater.py @@ -53,7 +53,7 @@ class ShowUpdater(): # clean out cache directory, remove everything > 12 hours old if sickbeard.CACHE_DIR: - for indexer in sickbeard.indexerApi.indexers(): + for indexer in sickbeard.indexerApi().indexers: cache_dir = sickbeard.indexerApi(indexer).cache logger.log(u"Trying to clean cache folder " + cache_dir) diff --git a/sickbeard/webserve.py b/sickbeard/webserve.py index 38f68e7d..4c58978a 100644 --- a/sickbeard/webserve.py +++ b/sickbeard/webserve.py @@ -179,7 +179,7 @@ def ManageMenu(): if sickbeard.USE_TORRENTS and sickbeard.TORRENT_METHOD != 'blackhole' \ and (sickbeard.ENABLE_HTTPS and sickbeard.TORRENT_HOST[:5] == 'https' - or not sickbeard.ENABLE_HTTPS and sickbeard.TORRENT_HOST[:5] == 'http:'): + or not sickbeard.ENABLE_HTTPS and sickbeard.TORRENT_HOST[:5] == 'http:'): manageMenu.append({'title': 'Manage Torrents', 'path': 'manage/manageTorrents/'}) if sickbeard.USE_SUBTITLES: @@ -381,7 +381,7 @@ class Manage: result[cur_season][cur_episode]["subtitles"] = ",".join( subliminal.language.Language(subtitle).alpha2 for subtitle in cur_result["subtitles"].split(',')) if not \ - cur_result["subtitles"] == '' else '' + cur_result["subtitles"] == '' else '' return json.dumps(result) @@ -1976,7 +1976,7 @@ class NewHomeAddShows: keywords.insert(0, nameUTF8) # check for indexer preset - indexers = sickbeard.indexerApi.indexers if not int(indexer) else [int(indexer or 0)] + indexers = sickbeard.indexerApi().indexers if not int(indexer) else [int(indexer or 0)] # Query Indexers for each search term and build the list of results for indexer in indexers(): @@ -1994,7 +1994,8 @@ class NewHomeAddShows: results += [[sickbeard.indexerApi(indexer).name, int(sickbeard.indexerApi(indexer).config['id']), sickbeard.indexerApi(indexer).config["show_url"], int(x['id']), x['seriesname'], x['firstaired']] for x in search if x['firstaired']] - except:continue + except: + continue # remove duplicates results = list(results for results, _ in itertools.groupby(results)) @@ -2066,7 +2067,7 @@ class NewHomeAddShows: # default to TVDB if indexer was not detected if show_name and (indexer is None or indexer_id is None): - for idx in sickbeard.indexerApi.indexers(): + for idx in sickbeard.indexerApi().indexers: found_info = helpers.searchIndexerForShowID(show_name, idx, indexer_id) if found_info: # set indexer and indexer_id from found info @@ -2573,7 +2574,7 @@ class Home: result = notifiers.nmj_notifier.notify_settings(urllib.unquote_plus(host)) if result: return '{"message": "Got settings from %(host)s", "database": "%(database)s", "mount": "%(mount)s"}' % { - "host": host, "database": sickbeard.NMJ_DATABASE, "mount": sickbeard.NMJ_MOUNT} + "host": host, "database": sickbeard.NMJ_DATABASE, "mount": sickbeard.NMJ_MOUNT} else: return '{"message": "Failed! Make sure your Popcorn is on and NMJ is running. (see Log & Errors -> Debug for detailed info)", "database": "", "mount": ""}' @@ -2599,7 +2600,7 @@ class Home: "database": sickbeard.NMJv2_DATABASE} else: return '{"message": "Unable to find NMJ Database at location: %(dbloc)s. Is the right location selected and PCH running?", "database": ""}' % { - "dbloc": dbloc} + "dbloc": dbloc} @cherrypy.expose def testTrakt(self, api=None, username=None, password=None): @@ -3633,7 +3634,7 @@ class WebInterface: # paused_item['title'] = 'Hide Paused' if sickbeard.COMING_EPS_DISPLAY_PAUSED else 'Show Paused' paused_item = {'title': 'View Paused:', 'path': {'': ''}} paused_item['path'] = {'Hide': 'toggleComingEpsDisplayPaused'} if sickbeard.COMING_EPS_DISPLAY_PAUSED else { - 'Show': 'toggleComingEpsDisplayPaused'} + 'Show': 'toggleComingEpsDisplayPaused'} t.submenu = [ {'title': 'Sort by:', 'path': {'Date': 'setComingEpsSort/?sort=date', 'Show': 'setComingEpsSort/?sort=show',