Bugfixes for post processing code

This commit is contained in:
echel0n 2014-03-10 00:01:46 -07:00
parent 0d9fbc1ad7
commit 45ba1e815b
6 changed files with 39 additions and 22 deletions

View File

@ -110,7 +110,7 @@ class FailedProcessor(object):
for show_name in show_names:
found_info = helpers.searchDBForShow(show_name)
if found_info is not None:
return(found_info[0])
return(found_info[1])
return None

View File

@ -320,7 +320,7 @@ def searchDBForShow(regShowName):
sqlResults = myDB.select("SELECT * FROM tv_shows WHERE show_name LIKE ? OR show_name LIKE ?", [showName, showName])
if len(sqlResults) == 1:
return (int(sqlResults[0]["indexer_id"]), sqlResults[0]["show_name"])
return (sqlResults[0]["indexer"], int(sqlResults[0]["indexer_id"]), sqlResults[0]["show_name"])
else:
@ -337,7 +337,7 @@ def searchDBForShow(regShowName):
logger.log(u"Multiple results for " + showName + " in the DB, unable to match show name", logger.DEBUG)
continue
else:
return (int(sqlResults[0]["indexer_id"]), sqlResults[0]["show_name"])
return (sqlResults[0]["indexer"], int(sqlResults[0]["indexer_id"]), sqlResults[0]["show_name"])
return None

View File

@ -26,6 +26,12 @@ class indexerApi:
return object.__new__(new_type)
def __init__(self, indexer=None, language=None, *args, **kwargs):
if indexer is not None:
self.name = eval(indexer)
self._wrapped = eval(indexer)(*args, **kwargs)
else:
self.name = "Indexer"
self.config = {}
self.config['valid_languages'] = [
@ -48,9 +54,6 @@ class indexerApi:
else:
self.config['language'] = language
if indexer is not None:
self._wrapped = eval(indexer)(*args, **kwargs)
def __getattr__(self, attr):
return getattr(self._wrapped, attr)

View File

@ -280,7 +280,7 @@ class NameParser(object):
for cur_name in name_list:
logger.log(u"Looking up "+cur_name+u" in the DB", logger.DEBUG)
db_result = sickbeard.helpers.searchDBForShow(cur_name)
if db_result: return db_result[0]
if db_result: return db_result[1]
# see if we can find the name with a TVDB lookup
if check_tvdb:

View File

@ -498,7 +498,7 @@ class PostProcessor(object):
self._log(u"Checking scene exceptions for a match on " + cur_name, logger.DEBUG)
scene_id = scene_exceptions.get_scene_exception_by_name(cur_name)
if scene_id:
self._log(u"Scene exception lookup got tvdb id " + str(scene_id) + ", using that", logger.DEBUG)
self._log(u"Scene exception lookup got a indexer id " + str(scene_id) + ", using that", logger.DEBUG)
_finalize(parse_result)
return (scene_id, season, episodes)
@ -507,37 +507,49 @@ class PostProcessor(object):
self._log(u"Looking up " + cur_name +u" in the DB", logger.DEBUG)
db_result = helpers.searchDBForShow(cur_name)
if db_result:
self._log(u"Lookup successful, using tvdb id " + str(db_result[0]), logger.DEBUG)
self._log(u"Lookup successful, using " + db_result[0] + " id " + str(db_result[0]), logger.DEBUG)
_finalize(parse_result)
return (int(db_result[0]), season, episodes)
return (int(db_result[1]), season, episodes)
# see if we can find the name with a TVDB lookup
for cur_name in name_list:
try:
sickbeard.INDEXER_API_PARMS['indexer'] = 'Tvdb'
t = indexer_api.indexerApi(custom_ui=classes.ShowListUI, **sickbeard.INDEXER_API_PARMS)
self._log(u"Looking up name " + cur_name + u" on " + self.indexer + "", logger.DEBUG)
self._log(u"Looking up name " + cur_name + u" on " + t.name + "", logger.DEBUG)
showObj = t[cur_name]
except (indexer_exceptions):
except (indexer_exceptions.indexer_exception, IOError):
# if none found, search on all languages
try:
# There's gotta be a better way of doing this but we don't wanna
# change the language value elsewhere
sickbeard.INDEXER_API_PARMS['indexer'] = 'Tvdb'
lINDEXER_API_PARMS = sickbeard.INDEXER_API_PARMS.copy()
lINDEXER_API_PARMS['search_all_languages'] = True
t = indexer_api.indexerApi(custom_ui=classes.ShowListUI, **lINDEXER_API_PARMS)
self._log(u"Looking up name " + cur_name + u" in all languages on " + self.indexer + "", logger.DEBUG)
self._log(u"Looking up name " + cur_name + u" in all languages on " + t.name + "", logger.DEBUG)
showObj = t[cur_name]
except (indexer_exceptions.indexer_exception, IOError):
pass
# if none found, search on TVRage
try:
sickbeard.INDEXER_API_PARMS['indexer'] = 'TVRage'
lINDEXER_API_PARMS = sickbeard.INDEXER_API_PARMS.copy()
t = indexer_api.indexerApi(custom_ui=classes.ShowListUI, **lINDEXER_API_PARMS)
self._log(u"Looking up name " + cur_name + u" in all languages on " + t.name + "", logger.DEBUG)
showObj = t[cur_name]
except (indexer_exceptions.indexer_exception, IOError):
pass
continue
except (IOError):
continue
self._log(u"Lookup successful, using tvdb id " + str(showObj["id"]), logger.DEBUG)
self._log(u"Lookup successful, using " + sickbeard.INDEXER_API_PARMS['indexer'] + " id " + str(showObj["id"]), logger.DEBUG)
_finalize(parse_result)
return (int(showObj["id"]), season, episodes)
@ -551,6 +563,7 @@ class PostProcessor(object):
"""
indexer_id = season = None
indexer = None
episodes = []
# try to look up the nzb in history
@ -600,6 +613,7 @@ class PostProcessor(object):
showObj = helpers.findCertainShow(sickbeard.showList, indexer_id)
if(showObj != None):
indexer_lang = showObj.lang
indexer = showObj.indexer
except exceptions.MultipleShowObjectsException:
raise #TODO: later I'll just log this, for now I want to know about it ASAP
@ -622,7 +636,7 @@ class PostProcessor(object):
episodes = []
continue
except indexer_exceptions.indexer_error, e:
logger.log(u"Unable to contact " + self.indexer + ": " + ex(e), logger.WARNING)
logger.log(u"Unable to contact " + showObj.indexer + ": " + ex(e), logger.WARNING)
episodes = []
continue
@ -635,9 +649,9 @@ class PostProcessor(object):
season = 1
if indexer_id and season != None and episodes:
return (indexer_id, season, episodes)
return (indexer, indexer_id, season, episodes)
return (indexer_id, season, episodes)
return (indexer, indexer_id, season, episodes)
def _get_ep_obj(self, indexer_id, season, episodes):
"""
@ -813,11 +827,11 @@ class PostProcessor(object):
self.in_history = False
# try to find the file info
(indexer_id, season, episodes) = self._find_info()
(indexer, indexer_id, season, episodes) = self._find_info()
# if we don't have it then give up
if not indexer_id or season == None or not episodes:
self._log(u"Can't find show id from " + self.indexer + " or season or episode, skipping", logger.WARNING)
self._log(u"Can't find show id from " + indexer + " or season or episode, skipping", logger.WARNING)
return False
# retrieve/create the corresponding TVEpisode objects

View File

@ -272,8 +272,8 @@ class TVCache():
logger.log(u"Trying to look the show up in the show database", logger.DEBUG)
showResult = helpers.searchDBForShow(parse_result.series_name)
if showResult:
logger.log(parse_result.series_name + " was found to be show " + showResult[1] + " ("+str(showResult[0])+") in our DB.", logger.DEBUG)
indexer_id = showResult[0]
logger.log(parse_result.series_name + " was found to be show " + showResult[2] + " ("+str(showResult[1])+") in our DB.", logger.DEBUG)
indexer_id = showResult[1]
# if the DB lookup fails then do a comprehensive regex search
if indexer_id == None: