Fixed up code for searching indexers for show id which fixes a bug that was present in our post processing code

This commit is contained in:
echel0n 2014-03-25 19:41:28 -07:00
parent 381f2e9e1a
commit ab124158a4
3 changed files with 38 additions and 51 deletions

View file

@ -300,18 +300,10 @@ def searchDBForShow(regShowName, indexer_id=None):
return None return None
def searchIndexersForShow(regShowName, indexer=None, indexer_id=None): def searchIndexerForShowID(regShowName, indexer, indexer_id=None):
showNames = [re.sub('[. -]', ' ', regShowName), regShowName] showNames = [re.sub('[. -]', ' ', regShowName), regShowName]
# check for indexer preset
try:
indexers = [int(indexer)]
except:
indexers = sickbeard.indexerApi().indexers
# Query Indexers for each search term and build the list of results # Query Indexers for each search term and build the list of results
for indexer in indexers:
def searchShows():
lINDEXER_API_PARMS = {'indexer': indexer} lINDEXER_API_PARMS = {'indexer': indexer}
lINDEXER_API_PARMS['custom_ui'] = classes.ShowListUI lINDEXER_API_PARMS['custom_ui'] = classes.ShowListUI
t = sickbeard.indexerApi(**lINDEXER_API_PARMS) t = sickbeard.indexerApi(**lINDEXER_API_PARMS)
@ -342,11 +334,6 @@ def searchIndexersForShow(regShowName, indexer=None, indexer_id=None):
except Exception, e: except Exception, e:
continue continue
# search indexers for shows
found = searchShows()
if found: return found
def sizeof_fmt(num): def sizeof_fmt(num):
''' '''
>>> sizeof_fmt(2) >>> sizeof_fmt(2)

View file

@ -518,22 +518,20 @@ class PostProcessor(object):
self._log(u"Looking up " + cur_name + u" in the DB", logger.DEBUG) self._log(u"Looking up " + cur_name + u" in the DB", logger.DEBUG)
db_result = helpers.searchDBForShow(cur_name) db_result = helpers.searchDBForShow(cur_name)
if db_result: if db_result:
self._log(u"Lookup successful, using " + db_result[0] + " id " + str(db_result[1]), logger.DEBUG) self._log(u"Lookup successful, using " + sickbeard.indexerApi(db_result[0]).name + " id " + str(
db_result[1]),
logger.DEBUG)
_finalize(parse_result) _finalize(parse_result)
return (int(db_result[1]), season, episodes) return (int(db_result[1]), season, episodes)
# see if we can find the name on the Indexer # see if we can find the name on the Indexer
for cur_name in name_list: for cur_name in name_list:
foundInfo = helpers.searchIndexersForShow(cur_name, indexer=self.indexer) foundInfo = helpers.searchIndexerForShowID(cur_name, self.indexer)
if foundInfo: if foundInfo:
indexer_id = foundInfo[1] indexer_id = foundInfo[1]
self._log( self._log(
u"Lookup successful, using " + sickbeard.indexerApi(self.indexer).name + " id " + str(indexer_id), u"Lookup successful, using " + sickbeard.indexerApi(self.indexer).name + " id " + str(indexer_id),
logger.DEBUG) logger.DEBUG)
# return found results
_finalize(parse_result) _finalize(parse_result)
return (indexer_id, season, episodes) return (indexer_id, season, episodes)
@ -597,7 +595,6 @@ class PostProcessor(object):
if (showObj != None): if (showObj != None):
# set the language of the show # set the language of the show
indexer_lang = showObj.lang indexer_lang = showObj.lang
self.indexer = int(showObj.indexer)
except exceptions.MultipleShowObjectsException: except exceptions.MultipleShowObjectsException:
raise #TODO: later I'll just log this, for now I want to know about it ASAP raise #TODO: later I'll just log this, for now I want to know about it ASAP

View file

@ -2068,8 +2068,8 @@ class NewHomeAddShows:
# default to TVDB if indexer was not detected # default to TVDB if indexer was not detected
if show_name and (indexer is None or indexer_id is None): if show_name and (indexer is None or indexer_id is None):
found_info = helpers.searchIndexersForShow(show_name, indexer_id=indexer_id) for idx in sickbeard.indexerApi().indexers:
found_info = helpers.searchIndexerForShowID(show_name, idx, indexer_id)
if found_info: if found_info:
# set indexer and indexer_id from found info # set indexer and indexer_id from found info
if indexer is None: if indexer is None:
@ -2078,6 +2078,9 @@ class NewHomeAddShows:
if indexer_id is None: if indexer_id is None:
indexer_id = found_info[1] indexer_id = found_info[1]
# found our info so continue
break
cur_dir['existing_info'] = (indexer_id, show_name, indexer) cur_dir['existing_info'] = (indexer_id, show_name, indexer)
if indexer_id and helpers.findCertainShow(sickbeard.showList, indexer_id): if indexer_id and helpers.findCertainShow(sickbeard.showList, indexer_id):