diff --git a/gui/slick/interfaces/default/home_massAddTable.tmpl b/gui/slick/interfaces/default/home_massAddTable.tmpl
index 6de79abf..2359ed12 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 c871c3a6..a151e93d 100644
--- a/sickbeard/helpers.py
+++ b/sickbeard/helpers.py
@@ -304,9 +304,9 @@ def searchIndexerForShowID(regShowName, indexer, indexer_id=None):
showNames = [re.sub('[. -]', ' ', regShowName), regShowName]
# Query Indexers for each search term and build the list of results
- lINDEXER_API_PARMS = {'indexer': indexer}
+ lINDEXER_API_PARMS = sickbeard.indexerApi(indexer).api_params.copy()
lINDEXER_API_PARMS['custom_ui'] = classes.ShowListUI
- t = sickbeard.indexerApi(**lINDEXER_API_PARMS)
+ t = sickbeard.indexerApi(indexer).indexer(**lINDEXER_API_PARMS)
for name in showNames:
logger.log(u"Trying to find " + name + " on " + sickbeard.indexerApi(indexer).name, logger.DEBUG)
@@ -326,7 +326,7 @@ def searchIndexerForShowID(regShowName, indexer, indexer_id=None):
name = name.encode('UTF-8').lower()
if (seriesname == name) or (indexer_id is not None and part['id'] == indexer_id):
- return [t.config['id'], part['id']]
+ return [sickbeard.indexerApi(indexer).config['id'], part['id']]
except KeyError, e:
break
@@ -942,38 +942,23 @@ 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 = {'indexer': indexer}
-
+ lINDEXER_API_PARMS = sickbeard.indexerApi(indexer).api_params.copy()
lINDEXER_API_PARMS['custom_ui'] = classes.ShowListUI
+ lINDEXER_API_PARMS['search_all_languages'] = True
- t = sickbeard.indexerApi(**lINDEXER_API_PARMS)
+ t = sickbeard.indexerApi(indexer).indexer(**lINDEXER_API_PARMS)
showObj = t[name]
- except (sickbeard.indexer_exception, IOError):
- # if none found, search on all languages
- try:
- lINDEXER_API_PARMS = {'indexer': indexer}
+ except:continue
- lINDEXER_API_PARMS['search_all_languages'] = True
- lINDEXER_API_PARMS['custom_ui'] = classes.ShowListUI
-
- t = sickbeard.indexerApi(**lINDEXER_API_PARMS)
- showObj = t[name]
- except (sickbeard.indexer_exception, IOError):
- pass
-
- continue
- except (IOError):
- continue
-
- showResult = findCertainShow(sickbeard.showList, int(showObj["id"]))
- if showResult is not None:
- return showResult
+ if showObj:
+ showResult = findCertainShow(sickbeard.showList, int(showObj["id"]))
+ if showResult is not None:
+ return showResult
return None
-
def suffix(d):
return 'th' if 11 <= d <= 13 else {1: 'st', 2: 'nd', 3: 'rd'}.get(d % 10, 'th')
diff --git a/sickbeard/indexers/indexer_api.py b/sickbeard/indexers/indexer_api.py
index b8b2c4dd..8d7ae2fa 100644
--- a/sickbeard/indexers/indexer_api.py
+++ b/sickbeard/indexers/indexer_api.py
@@ -20,28 +20,37 @@ import sickbeard
from indexer_config import initConfig, indexerConfig
-
class indexerApi(object):
- def __init__(self, indexer=None, *args, **kwargs):
- self._wrapped = object
- self.config = initConfig
- self.indexers = {k: v if k is 'id' else v['name'] for k, v in indexerConfig.items()}
+ def __init__(self, indexerID=None):
+ self.indexerID = indexerID
- if indexer in indexerConfig:
- self.name = indexerConfig[indexer]['name']
- self.config = indexerConfig[indexer]
+ def indexer(self, *args, **kwargs):
+ if self.indexerID:
+ return indexerConfig[self.indexerID]['module'](*args, **kwargs)
- # set cache if exists
- if sickbeard.CACHE_DIR: indexerConfig[indexer]['api_params']['cache'] = os.path.join(sickbeard.CACHE_DIR,
- self.name)
- # update API params
- indexerConfig[indexer]['api_params'].update(**kwargs)
+ @property
+ def config(self):
+ if self.indexerID:
+ return indexerConfig[self.indexerID]
+ return initConfig
- # wrap the indexer API object and return it back
- self._wrapped = indexerConfig[indexer]['module'](*args, **indexerConfig[indexer]['api_params'])
+ @property
+ def name(self):
+ if self.indexerID:
+ return indexerConfig[self.indexerID]['name']
- def __getattr__(self, attr):
- return getattr(self._wrapped, attr)
+ @property
+ 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)
+ return indexerConfig[self.indexerID]['api_params']
- def __getitem__(self, attr):
- return self._wrapped.__getitem__(attr)
+ @property
+ def cache(self):
+ if sickbeard.CACHE_DIR:
+ return self.api_params['cache']
+
+ @staticmethod
+ def indexers():
+ 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/indexers/test/test.py b/sickbeard/indexers/test/test.py
index bd8f5e13..c0690a22 100644
--- a/sickbeard/indexers/test/test.py
+++ b/sickbeard/indexers/test/test.py
@@ -11,91 +11,26 @@ sys.path.append(os.path.abspath('..'))
sys.path.append(os.path.abspath('../../../lib'))
import sickbeard
-import itertools
-
-from itertools import chain
-from sickbeard import classes
-
class APICheck(unittest.TestCase):
- indexer = u'3'
-
- for i in int([indexer]) and sickbeard.indexerApi().indexers:
- print i
-
- global indexer, keywords, nameUTF8
-
- indexer = 0
- name = 'american dad'
+ indexer_id = 2930
lang = "en"
- if not lang or lang == 'null':
- lang = "en"
+ for indexer in sickbeard.indexerApi.indexers():
+ print indexer
+ print sickbeard.indexerApi().config['langabbv_to_id'][lang]
+ print sickbeard.indexerApi(indexer).cache
+ print sickbeard.indexerApi(indexer).name
+ print sickbeard.indexerApi(indexer).config['scene_url']
+ print sickbeard.indexerApi().config['valid_languages']
- results = []
+ lINDEXER_API_PARMS = sickbeard.indexerApi(indexer).api_params.copy()
+ lINDEXER_API_PARMS['cache'] = True
+ t = sickbeard.indexerApi(indexer).indexer(**lINDEXER_API_PARMS)
+ epObj = t[indexer_id].airedOn(1)[0]
- nameUTF8 = name.encode('utf-8')
-
- # Use each word in the show's name as a possible search term
- keywords = nameUTF8.split(' ')
-
- # Insert the whole show's name as the first search term so best results are first
- # ex: keywords = ['Some Show Name', 'Some', 'Show', 'Name']
- if len(keywords) > 1:
- keywords.insert(0, nameUTF8)
-
-
- # check for indexer preset
- indexers = [int(indexer)]
- if 0 in indexers:
- indexers = sickbeard.indexerApi().indexers
-
- # Query Indexers for each search term and build the list of results
- for i in indexers:
- def searchShows(i):
- results = []
-
- lINDEXER_API_PARMS = {'indexer': i}
- lINDEXER_API_PARMS['custom_ui'] = classes.AllShowsListUI
- t = sickbeard.indexerApi(**lINDEXER_API_PARMS)
-
- for searchTerm in keywords:
- try:
- search = t[searchTerm]
- if isinstance(search, dict):
- search = [search]
-
- # add search results
- result = [
- [t.name, t.config['id'], t.config["show_url"], int(x['id']), x['seriesname'], x['firstaired']]
- for x in search if nameUTF8.lower() in x['seriesname'].lower()]
-
- # see if we have any matches
- if len(result) > 0:
- # add result to list of found shows
- results += result
-
- # search through result to see if we have a exact match
- for show in result:
- # cleanup the series name
- seriesname = show[4].encode('utf-8').translate(None, string.punctuation)
-
- # check if we got a exact match
- if nameUTF8.lower() == seriesname.lower():
- return results
-
- except Exception, e:
- continue
-
- # finished searching a indexer so return the results
- return results
-
- # search indexers for shows
- results += searchShows(i)
-
- # remove duplicates
- results = list(results for results, _ in itertools.groupby(results))
- print results
+ season = int(epObj["seasonnumber"])
+ episodes = [int(epObj["episodenumber"])]
if __name__ == "__main__":
unittest.main()
\ No newline at end of file
diff --git a/sickbeard/metadata/generic.py b/sickbeard/metadata/generic.py
index 16b906c7..2db36abb 100644
--- a/sickbeard/metadata/generic.py
+++ b/sickbeard/metadata/generic.py
@@ -349,7 +349,7 @@ class GenericMetadata():
try:
# There's gotta be a better way of doing this but we don't wanna
# change the language value elsewhere
- lINDEXER_API_PARMS = {'indexer': ep_obj.show.indexer}
+ lINDEXER_API_PARMS = sickbeard.indexerApi(ep_obj.show.indexer).api_params.copy()
lINDEXER_API_PARMS['actors'] = True
@@ -359,7 +359,7 @@ class GenericMetadata():
if ep_obj.show.dvdorder != 0:
lINDEXER_API_PARMS['dvdorder'] = True
- t = sickbeard.indexerApi(**lINDEXER_API_PARMS)
+ t = sickbeard.indexerApi(ep_obj.show.indexer).indexer(**lINDEXER_API_PARMS)
indexer_show_obj = t[ep_obj.show.indexerid]
except sickbeard.indexer_shownotfound, e:
@@ -739,7 +739,7 @@ class GenericMetadata():
try:
# There's gotta be a better way of doing this but we don't wanna
# change the language value elsewhere
- lINDEXER_API_PARMS = {'indexer': show_obj.indexer}
+ lINDEXER_API_PARMS = sickbeard.indexerApi(show_obj.indexer).api_params.copy()
lINDEXER_API_PARMS['banners'] = True
@@ -749,7 +749,7 @@ class GenericMetadata():
if show_obj.dvdorder != 0:
lINDEXER_API_PARMS['dvdorder'] = True
- t = sickbeard.indexerApi(**lINDEXER_API_PARMS)
+ t = sickbeard.indexerApi(show_obj.indexer).indexer(**lINDEXER_API_PARMS)
indexer_show_obj = t[show_obj.indexerid]
except (sickbeard.indexer_error, IOError), e:
logger.log(u"Unable to look up show on " + sickbeard.indexerApi(
@@ -804,7 +804,7 @@ class GenericMetadata():
try:
# There's gotta be a better way of doing this but we don't wanna
# change the language value elsewhere
- lINDEXER_API_PARMS = {'indexer': show_obj.indexer}
+ lINDEXER_API_PARMS = sickbeard.indexerApi(show_obj.indexer).api_params.copy()
lINDEXER_API_PARMS['banners'] = True
@@ -814,7 +814,7 @@ class GenericMetadata():
if show_obj.dvdorder != 0:
lINDEXER_API_PARMS['dvdorder'] = True
- t = sickbeard.indexerApi(**lINDEXER_API_PARMS)
+ t = sickbeard.indexerApi(show_obj.indexer).indexer(**lINDEXER_API_PARMS)
indexer_show_obj = t[show_obj.indexerid]
except (sickbeard.indexer_error, IOError), e:
logger.log(u"Unable to look up show on " + sickbeard.indexerApi(
@@ -860,14 +860,14 @@ class GenericMetadata():
try:
# There's gotta be a better way of doing this but we don't wanna
# change the language value elsewhere
- lINDEXER_API_PARMS = {'indexer': show_obj.indexer}
+ lINDEXER_API_PARMS = sickbeard.indexerApi(show_obj.indexer).api_params.copy()
lINDEXER_API_PARMS['banners'] = True
if indexer_lang and not indexer_lang == 'en':
lINDEXER_API_PARMS['language'] = indexer_lang
- t = sickbeard.indexerApi(**lINDEXER_API_PARMS)
+ t = sickbeard.indexerApi(show_obj.indexer).indexer(**lINDEXER_API_PARMS)
indexer_show_obj = t[show_obj.indexerid]
except (sickbeard.indexer_error, IOError), e:
logger.log(u"Unable to look up show on " + sickbeard.indexerApi(
diff --git a/sickbeard/metadata/mediabrowser.py b/sickbeard/metadata/mediabrowser.py
index e3647298..34409446 100644
--- a/sickbeard/metadata/mediabrowser.py
+++ b/sickbeard/metadata/mediabrowser.py
@@ -228,7 +228,7 @@ class MediaBrowserMetadata(generic.GenericMetadata):
indexer_lang = show_obj.lang
# There's gotta be a better way of doing this but we don't wanna
# change the language value elsewhere
- lINDEXER_API_PARMS = {'indexer': show_obj.indexer}
+ lINDEXER_API_PARMS = sickbeard.indexerApi(show_obj.indexer).api_params.copy()
lINDEXER_API_PARMS['actors'] = True
@@ -238,7 +238,7 @@ class MediaBrowserMetadata(generic.GenericMetadata):
if show_obj.dvdorder != 0:
lINDEXER_API_PARMS['dvdorder'] = True
- t = sickbeard.indexerApi(**lINDEXER_API_PARMS)
+ t = sickbeard.indexerApi(show_obj.indexer).indexer(**lINDEXER_API_PARMS)
tv_node = etree.Element("Series")
@@ -395,7 +395,7 @@ class MediaBrowserMetadata(generic.GenericMetadata):
indexer_lang = ep_obj.show.lang
try:
- lINDEXER_API_PARMS = {'indexer': ep_obj.show.indexer}
+ lINDEXER_API_PARMS = sickbeard.indexerApi(ep_obj.show.indexer).api_params.copy()
lINDEXER_API_PARMS['actors'] = True
@@ -405,7 +405,7 @@ class MediaBrowserMetadata(generic.GenericMetadata):
if ep_obj.show.dvdorder != 0:
lINDEXER_API_PARMS['dvdorder'] = True
- t = sickbeard.indexerApi(**lINDEXER_API_PARMS)
+ t = sickbeard.indexerApi(ep_obj.show.indexer).indexer(**lINDEXER_API_PARMS)
myShow = t[ep_obj.show.indexerid]
except sickbeard.indexer_shownotfound, e:
diff --git a/sickbeard/metadata/tivo.py b/sickbeard/metadata/tivo.py
index 485e1601..06b88a0d 100644
--- a/sickbeard/metadata/tivo.py
+++ b/sickbeard/metadata/tivo.py
@@ -166,7 +166,7 @@ class TIVOMetadata(generic.GenericMetadata):
indexer_lang = ep_obj.show.lang
try:
- lINDEXER_API_PARMS = {'indexer': ep_obj.show.indexer}
+ lINDEXER_API_PARMS = sickbeard.indexerApi(ep_obj.show.indexer).api_params.copy()
lINDEXER_API_PARMS['actors'] = True
@@ -176,7 +176,7 @@ class TIVOMetadata(generic.GenericMetadata):
if ep_obj.show.dvdorder != 0:
lINDEXER_API_PARMS['dvdorder'] = True
- t = sickbeard.indexerApi(**lINDEXER_API_PARMS)
+ t = sickbeard.indexerApi(ep_obj.show.indexer).indexer(**lINDEXER_API_PARMS)
myShow = t[ep_obj.show.indexerid]
except sickbeard.indexer_shownotfound, e:
raise exceptions.ShowNotFoundException(str(e))
diff --git a/sickbeard/metadata/wdtv.py b/sickbeard/metadata/wdtv.py
index 34e572f8..1ef8418e 100644
--- a/sickbeard/metadata/wdtv.py
+++ b/sickbeard/metadata/wdtv.py
@@ -177,7 +177,7 @@ class WDTVMetadata(generic.GenericMetadata):
indexer_lang = ep_obj.show.lang
try:
- lINDEXER_API_PARMS = {'indexer': ep_obj.show.indexer}
+ lINDEXER_API_PARMS = sickbeard.indexerApi(ep_obj.show.indexer).api_params.copy()
lINDEXER_API_PARMS['actors'] = True
@@ -187,7 +187,7 @@ class WDTVMetadata(generic.GenericMetadata):
if ep_obj.show.dvdorder != 0:
lINDEXER_API_PARMS['dvdorder'] = True
- t = sickbeard.indexerApi(**lINDEXER_API_PARMS)
+ t = sickbeard.indexerApi(ep_obj.show.indexer).indexer(**lINDEXER_API_PARMS)
myShow = t[ep_obj.show.indexerid]
except sickbeard.indexer_shownotfound, e:
raise exceptions.ShowNotFoundException(e.message)
diff --git a/sickbeard/metadata/xbmc_12plus.py b/sickbeard/metadata/xbmc_12plus.py
index 0016e4ce..64106ccf 100644
--- a/sickbeard/metadata/xbmc_12plus.py
+++ b/sickbeard/metadata/xbmc_12plus.py
@@ -97,7 +97,7 @@ class XBMC_12PlusMetadata(generic.GenericMetadata):
show_ID = show_obj.indexerid
indexer_lang = show_obj.lang
- lINDEXER_API_PARMS = {'indexer': show_obj.indexer}
+ lINDEXER_API_PARMS = sickbeard.indexerApi(show_obj.indexer).api_params.copy()
lINDEXER_API_PARMS['actors'] = True
@@ -107,7 +107,7 @@ class XBMC_12PlusMetadata(generic.GenericMetadata):
if show_obj.dvdorder != 0:
lINDEXER_API_PARMS['dvdorder'] = True
- t = sickbeard.indexerApi(**lINDEXER_API_PARMS)
+ t = sickbeard.indexerApi(show_obj.indexer).indexer(**lINDEXER_API_PARMS)
tv_node = etree.Element("tvshow")
@@ -221,7 +221,7 @@ class XBMC_12PlusMetadata(generic.GenericMetadata):
indexer_lang = ep_obj.show.lang
- lINDEXER_API_PARMS = {'indexer': ep_obj.show.indexer}
+ lINDEXER_API_PARMS = sickbeard.indexerApi(ep_obj.show.indexer).api_params.copy()
lINDEXER_API_PARMS['actors'] = True
@@ -232,7 +232,7 @@ class XBMC_12PlusMetadata(generic.GenericMetadata):
lINDEXER_API_PARMS['dvdorder'] = True
try:
- t = sickbeard.indexerApi(**lINDEXER_API_PARMS)
+ t = sickbeard.indexerApi(ep_obj.show.indexer).indexer(**lINDEXER_API_PARMS)
myShow = t[ep_obj.show.indexerid]
except sickbeard.indexer_shownotfound, e:
raise exceptions.ShowNotFoundException(e.message)
diff --git a/sickbeard/name_parser/parser.py b/sickbeard/name_parser/parser.py
index 86373d7d..e8ac18d5 100644
--- a/sickbeard/name_parser/parser.py
+++ b/sickbeard/name_parser/parser.py
@@ -284,13 +284,13 @@ 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 = {'indexer': indexer}
+ lINDEXER_API_PARMS = sickbeard.indexerApi(indexer).api_params.copy()
lINDEXER_API_PARMS['custom_ui'] = classes.ShowListUI
- t = sickbeard.indexerApi(**lINDEXER_API_PARMS)
+ t = sickbeard.indexerApi(indexer).indexer(**lINDEXER_API_PARMS)
logger.log(u"Looking up name " + str(cur_name) + " on " + sickbeard.indexerApi(indexer).name,
logger.DEBUG)
@@ -298,12 +298,12 @@ class NameParser(object):
except (sickbeard.indexer_exception):
# if none found, search on all languages
try:
- lINDEXER_API_PARMS = {'indexer': indexer}
+ lINDEXER_API_PARMS = sickbeard.indexerApi(indexer).api_params.copy()
lINDEXER_API_PARMS['custom_ui'] = classes.ShowListUI
lINDEXER_API_PARMS['search_all_languages'] = True
- t = sickbeard.indexerApi(**lINDEXER_API_PARMS)
+ t = sickbeard.indexerApi(indexer).indexer(**lINDEXER_API_PARMS)
logger.log(
u"Looking up name " + str(cur_name) + " in all languages on " + sickbeard.indexerApi(
diff --git a/sickbeard/postProcessor.py b/sickbeard/postProcessor.py
index 72ea782c..f84e2fc2 100644
--- a/sickbeard/postProcessor.py
+++ b/sickbeard/postProcessor.py
@@ -599,12 +599,11 @@ class PostProcessor(object):
raise #TODO: later I'll just log this, for now I want to know about it ASAP
try:
- lINDEXER_API_PARMS = {'indexer': self.indexer}
-
+ lINDEXER_API_PARMS = sickbeard.indexerApi(self.indexer).api_params.copy()
if indexer_lang and not indexer_lang == 'en':
lINDEXER_API_PARMS = {'language': indexer_lang}
- t = sickbeard.indexerApi(**lINDEXER_API_PARMS)
+ t = sickbeard.indexerApi(self.indexer).indexer(**lINDEXER_API_PARMS)
epObj = t[indexer_id].airedOn(episodes[0])[0]
@@ -831,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/properFinder.py b/sickbeard/properFinder.py
index 387ba4e9..b2ed3484 100644
--- a/sickbeard/properFinder.py
+++ b/sickbeard/properFinder.py
@@ -169,14 +169,12 @@ class ProperFinder():
raise Exception("BAD STUFF HAPPENED")
indexer_lang = showObj.lang
-
- lINDEXER_API_PARMS = {'indexer': showObj.indexer}
-
+ lINDEXER_API_PARMS = sickbeard.indexerApi(showObj.indexer).api_params.copy()
if indexer_lang and not indexer_lang == 'en':
lINDEXER_API_PARMS['language'] = indexer_lang
try:
- t = sickbeard.indexerApi(**lINDEXER_API_PARMS)
+ t = sickbeard.indexerApi(showObj.indexer).indexer(**lINDEXER_API_PARMS)
epObj = t[curProper.indexerid].airedOn(curProper.episode)[0]
diff --git a/sickbeard/scene_exceptions.py b/sickbeard/scene_exceptions.py
index cc17e345..16d1af7c 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 77fffa3d..7207d439 100644
--- a/sickbeard/showUpdater.py
+++ b/sickbeard/showUpdater.py
@@ -53,8 +53,8 @@ class ShowUpdater():
# clean out cache directory, remove everything > 12 hours old
if sickbeard.CACHE_DIR:
- for indexer in sickbeard.indexerApi().indexers:
- cache_dir = sickbeard.indexerApi(indexer).config['api_params']['cache']
+ for indexer in sickbeard.indexerApi.indexers():
+ cache_dir = sickbeard.indexerApi(indexer).cache
logger.log(u"Trying to clean cache folder " + cache_dir)
# Does our cache_dir exists
diff --git a/sickbeard/show_queue.py b/sickbeard/show_queue.py
index 674051b0..e039d7fc 100644
--- a/sickbeard/show_queue.py
+++ b/sickbeard/show_queue.py
@@ -240,14 +240,13 @@ class QueueItemAdd(ShowQueueItem):
# make sure the indexer ids are valid
try:
- lINDEXER_API_PARMS = {'indexer': self.indexer}
-
+ lINDEXER_API_PARMS = sickbeard.indexerApi(self.indexer).api_params.copy()
if self.lang:
lINDEXER_API_PARMS['language'] = self.lang
logger.log(u"" + sickbeard.indexerApi(self.indexer).name + ": " + repr(lINDEXER_API_PARMS))
- t = sickbeard.indexerApi(**lINDEXER_API_PARMS)
+ t = sickbeard.indexerApi(self.indexer).indexer(**lINDEXER_API_PARMS)
s = t[self.indexer_id]
# this usually only happens if they have an NFO in their show dir which gave us a indexer ID that has no proper english version of the show
diff --git a/sickbeard/tv.py b/sickbeard/tv.py
index 5d6ace9b..c4611d25 100644
--- a/sickbeard/tv.py
+++ b/sickbeard/tv.py
@@ -98,10 +98,8 @@ class TVShow(object):
if ek.ek(os.path.isdir, self._location):
return self._location
- elif self._isDirGood:
- return self._location
else:
- raise exceptions.NoNFOException("Show folder doesn't exist, you shouldn't be using it")
+ raise exceptions.ShowDirNotFoundException("Show folder doesn't exist, you shouldn't be using it")
def _setLocation(self, newLocation):
logger.log(u"Setter sets location to " + newLocation, logger.DEBUG)
@@ -358,7 +356,7 @@ class TVShow(object):
scannedEps = {}
- lINDEXER_API_PARMS = {'indexer': self.indexer}
+ lINDEXER_API_PARMS = sickbeard.indexerApi(self.indexer).api_params.copy()
if self.lang:
lINDEXER_API_PARMS['language'] = self.lang
@@ -366,7 +364,7 @@ class TVShow(object):
if self.dvdorder != 0:
lINDEXER_API_PARMS['dvdorder'] = True
- t = sickbeard.indexerApi(**lINDEXER_API_PARMS)
+ t = sickbeard.indexerApi(self.indexer).indexer(**lINDEXER_API_PARMS)
cachedShow = t[self.indexerid]
cachedSeasons = {}
@@ -409,7 +407,7 @@ class TVShow(object):
def loadEpisodesFromIndexer(self, cache=True):
- lINDEXER_API_PARMS = {'indexer': self.indexer}
+ lINDEXER_API_PARMS = sickbeard.indexerApi(self.indexer).api_params.copy()
if not cache:
lINDEXER_API_PARMS['cache'] = False
@@ -421,7 +419,7 @@ class TVShow(object):
lINDEXER_API_PARMS['dvdorder'] = True
try:
- t = sickbeard.indexerApi(**lINDEXER_API_PARMS)
+ t = sickbeard.indexerApi(self.indexer).indexer(**lINDEXER_API_PARMS)
showObj = t[self.indexerid]
except sickbeard.indexer_error:
logger.log(u"" + sickbeard.indexerApi(
@@ -522,7 +520,7 @@ class TVShow(object):
# if we have an air-by-date show then get the real season/episode numbers
if parse_result.air_by_date:
try:
- lINDEXER_API_PARMS = {'indexer': self.indexer}
+ lINDEXER_API_PARMS = sickbeard.indexerApi(self.indexer).api_params.copy()
if self.lang:
lINDEXER_API_PARMS['language'] = self.lang
@@ -530,7 +528,7 @@ class TVShow(object):
if self.dvdorder != 0:
lINDEXER_API_PARMS['dvdorder'] = True
- t = sickbeard.indexerApi(**lINDEXER_API_PARMS)
+ t = sickbeard.indexerApi(self.indexer).indexer(**lINDEXER_API_PARMS)
epObj = t[self.indexerid].airedOn(parse_result.air_date)[0]
season = int(epObj["seasonnumber"])
@@ -731,7 +729,7 @@ class TVShow(object):
# There's gotta be a better way of doing this but we don't wanna
# change the cache value elsewhere
if tvapi is None:
- lINDEXER_API_PARMS = {'indexer': self.indexer}
+ lINDEXER_API_PARMS = sickbeard.indexerApi(self.indexer).api_params.copy()
if not cache:
lINDEXER_API_PARMS['cache'] = False
@@ -742,7 +740,7 @@ class TVShow(object):
if self.dvdorder != 0:
lINDEXER_API_PARMS['dvdorder'] = True
- t = sickbeard.indexerApi(**lINDEXER_API_PARMS)
+ t = sickbeard.indexerApi(self.indexer).indexer(**lINDEXER_API_PARMS)
else:
t = tvapi
@@ -1373,7 +1371,7 @@ class TVEpisode(object):
try:
if cachedSeason is None:
if tvapi is None:
- lINDEXER_API_PARMS = {'indexer': self.indexer}
+ lINDEXER_API_PARMS = sickbeard.indexerApi(self.indexer).api_params.copy()
if not cache:
lINDEXER_API_PARMS['cache'] = False
@@ -1384,7 +1382,7 @@ class TVEpisode(object):
if self.show.dvdorder != 0:
lINDEXER_API_PARMS['dvdorder'] = True
- t = sickbeard.indexerApi(**lINDEXER_API_PARMS)
+ t = sickbeard.indexerApi(self.indexer).indexer(**lINDEXER_API_PARMS)
else:
t = tvapi
myEp = t[self.show.indexerid][season][episode]
diff --git a/sickbeard/tvcache.py b/sickbeard/tvcache.py
index 9aff865c..3c996b53 100644
--- a/sickbeard/tvcache.py
+++ b/sickbeard/tvcache.py
@@ -304,12 +304,12 @@ class TVCache():
# if we have an air-by-date show then get the real season/episode numbers
if parse_result.air_by_date and indexer_id:
try:
- lINDEXER_API_PARMS = {'indexer': self.indexer}
+ lINDEXER_API_PARMS = sickbeard.indexerApi(self.indexer).api_params.copy()
if not (indexer_lang == "" or indexer_lang == "en" or indexer_lang == None):
lINDEXER_API_PARMS['language'] = indexer_lang
- t = sickbeard.indexerApi(**lINDEXER_API_PARMS)
+ t = sickbeard.indexerApi(self.indexer).indexer(**lINDEXER_API_PARMS)
epObj = t[indexer_id].airedOn(parse_result.air_date)[0]
season = int(epObj["seasonnumber"])
diff --git a/sickbeard/webapi.py b/sickbeard/webapi.py
index 2d52a670..c1d5a1f9 100644
--- a/sickbeard/webapi.py
+++ b/sickbeard/webapi.py
@@ -1599,13 +1599,15 @@ class CMD_SickBeardSearchTVDB(ApiCall):
return _responds(RESULT_SUCCESS, {"results": results, "langid": lang_id})
elif self.indexerid:
- lINDEXER_API_PARMS = {'indexer': self.indexer}
+ lINDEXER_API_PARMS = sickbeard.indexerApi(self.indexer).api_params.copy()
lang_id = self.valid_languages[self.lang]
if self.lang and not self.lang == 'en':
lINDEXER_API_PARMS['language'] = self.lang
- t = sickbeard.indexerApi(actors=False, **lINDEXER_API_PARMS)
+ lINDEXER_API_PARMS['actors'] = False
+
+ t = sickbeard.indexerApi(self.indexer).indexer(**lINDEXER_API_PARMS)
try:
myShow = t[int(self.indexerid)]
diff --git a/sickbeard/webserve.py b/sickbeard/webserve.py
index 44438deb..38f68e7d 100644
--- a/sickbeard/webserve.py
+++ b/sickbeard/webserve.py
@@ -1976,14 +1976,13 @@ class NewHomeAddShows:
keywords.insert(0, nameUTF8)
# check for indexer preset
- indexers = [int(indexer)]
- if 0 in indexers:
- indexers = sickbeard.indexerApi().indexers
+ 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 i in indexers:
- lINDEXER_API_PARMS = {'indexer': i, 'custom_ui': classes.AllShowsListUI}
- t = sickbeard.indexerApi(**lINDEXER_API_PARMS)
+ for indexer in indexers():
+ lINDEXER_API_PARMS = sickbeard.indexerApi(indexer).api_params.copy()
+ lINDEXER_API_PARMS['custom_ui'] = classes.AllShowsListUI
+ t = sickbeard.indexerApi(indexer).indexer(**lINDEXER_API_PARMS)
for searchTerm in keywords:
try:
@@ -1992,11 +1991,10 @@ class NewHomeAddShows:
search = [search]
# add search results
- results += [[t.name, t.config['id'], t.config["show_url"], int(x['id']), x['seriesname'],
- x['firstaired']] for x in search]
-
- except Exception, e:
- continue
+ 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
# remove duplicates
results = list(results for results, _ in itertools.groupby(results))
@@ -2068,7 +2066,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