1
0
mirror of https://github.com/moparisthebest/SickRage synced 2024-12-12 11:02:21 -05:00

Improved code for searching existing shows to find there indexerID and Indexer that they belong to for speed and accuracy

This commit is contained in:
echel0n 2014-03-25 11:50:11 -07:00
parent 872389d055
commit b8048a7e57

View File

@ -322,19 +322,18 @@ def searchIndexersForShow(regShowName, indexer_id=None):
search = [search]
# add search results
result = [[t.config['id'], x['id']] for x in search if name.lower() == x['seriesname'].lower()]
if len(result) > 0:
result = [item for sublist in result for item in sublist]
return result
for i in range(len(search)):
part = search[i]
seriesname = part['seriesname'].encode('UTF-8').lower()
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']]
except KeyError, e:
break
except Exception, e:
logger.log(
u"Error while auto-detecting show indexer and indexerid on indexer " + sickbeard.indexerApi(
indexer).name + ", retrying: " + ex(e), logger.ERROR)
logger.log(traceback.format_exc(), logger.DEBUG)
continue
# search indexers for shows