mirror of
https://github.com/moparisthebest/SickRage
synced 2024-12-12 11:02:21 -05:00
Bugfixes for post processing code
This commit is contained in:
parent
0d9fbc1ad7
commit
45ba1e815b
@ -110,7 +110,7 @@ class FailedProcessor(object):
|
|||||||
for show_name in show_names:
|
for show_name in show_names:
|
||||||
found_info = helpers.searchDBForShow(show_name)
|
found_info = helpers.searchDBForShow(show_name)
|
||||||
if found_info is not None:
|
if found_info is not None:
|
||||||
return(found_info[0])
|
return(found_info[1])
|
||||||
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
@ -320,7 +320,7 @@ def searchDBForShow(regShowName):
|
|||||||
sqlResults = myDB.select("SELECT * FROM tv_shows WHERE show_name LIKE ? OR show_name LIKE ?", [showName, showName])
|
sqlResults = myDB.select("SELECT * FROM tv_shows WHERE show_name LIKE ? OR show_name LIKE ?", [showName, showName])
|
||||||
|
|
||||||
if len(sqlResults) == 1:
|
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:
|
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)
|
logger.log(u"Multiple results for " + showName + " in the DB, unable to match show name", logger.DEBUG)
|
||||||
continue
|
continue
|
||||||
else:
|
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
|
return None
|
||||||
|
@ -26,6 +26,12 @@ class indexerApi:
|
|||||||
return object.__new__(new_type)
|
return object.__new__(new_type)
|
||||||
|
|
||||||
def __init__(self, indexer=None, language=None, *args, **kwargs):
|
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 = {}
|
||||||
|
|
||||||
self.config['valid_languages'] = [
|
self.config['valid_languages'] = [
|
||||||
@ -48,9 +54,6 @@ class indexerApi:
|
|||||||
else:
|
else:
|
||||||
self.config['language'] = language
|
self.config['language'] = language
|
||||||
|
|
||||||
if indexer is not None:
|
|
||||||
self._wrapped = eval(indexer)(*args, **kwargs)
|
|
||||||
|
|
||||||
def __getattr__(self, attr):
|
def __getattr__(self, attr):
|
||||||
return getattr(self._wrapped, attr)
|
return getattr(self._wrapped, attr)
|
||||||
|
|
||||||
|
@ -280,7 +280,7 @@ class NameParser(object):
|
|||||||
for cur_name in name_list:
|
for cur_name in name_list:
|
||||||
logger.log(u"Looking up "+cur_name+u" in the DB", logger.DEBUG)
|
logger.log(u"Looking up "+cur_name+u" in the DB", logger.DEBUG)
|
||||||
db_result = sickbeard.helpers.searchDBForShow(cur_name)
|
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
|
# see if we can find the name with a TVDB lookup
|
||||||
if check_tvdb:
|
if check_tvdb:
|
||||||
|
@ -498,7 +498,7 @@ class PostProcessor(object):
|
|||||||
self._log(u"Checking scene exceptions for a match on " + cur_name, logger.DEBUG)
|
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)
|
scene_id = scene_exceptions.get_scene_exception_by_name(cur_name)
|
||||||
if scene_id:
|
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)
|
_finalize(parse_result)
|
||||||
return (scene_id, season, episodes)
|
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)
|
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 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)
|
_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
|
# see if we can find the name with a TVDB lookup
|
||||||
for cur_name in name_list:
|
for cur_name in name_list:
|
||||||
try:
|
try:
|
||||||
|
sickbeard.INDEXER_API_PARMS['indexer'] = 'Tvdb'
|
||||||
t = indexer_api.indexerApi(custom_ui=classes.ShowListUI, **sickbeard.INDEXER_API_PARMS)
|
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]
|
showObj = t[cur_name]
|
||||||
except (indexer_exceptions):
|
except (indexer_exceptions.indexer_exception, IOError):
|
||||||
# if none found, search on all languages
|
# if none found, search on all languages
|
||||||
try:
|
try:
|
||||||
# There's gotta be a better way of doing this but we don't wanna
|
# There's gotta be a better way of doing this but we don't wanna
|
||||||
# change the language value elsewhere
|
# change the language value elsewhere
|
||||||
|
sickbeard.INDEXER_API_PARMS['indexer'] = 'Tvdb'
|
||||||
lINDEXER_API_PARMS = sickbeard.INDEXER_API_PARMS.copy()
|
lINDEXER_API_PARMS = sickbeard.INDEXER_API_PARMS.copy()
|
||||||
|
|
||||||
lINDEXER_API_PARMS['search_all_languages'] = True
|
lINDEXER_API_PARMS['search_all_languages'] = True
|
||||||
t = indexer_api.indexerApi(custom_ui=classes.ShowListUI, **lINDEXER_API_PARMS)
|
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]
|
showObj = t[cur_name]
|
||||||
except (indexer_exceptions.indexer_exception, IOError):
|
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
|
continue
|
||||||
except (IOError):
|
except (IOError):
|
||||||
continue
|
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)
|
_finalize(parse_result)
|
||||||
return (int(showObj["id"]), season, episodes)
|
return (int(showObj["id"]), season, episodes)
|
||||||
|
|
||||||
@ -551,6 +563,7 @@ class PostProcessor(object):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
indexer_id = season = None
|
indexer_id = season = None
|
||||||
|
indexer = None
|
||||||
episodes = []
|
episodes = []
|
||||||
|
|
||||||
# try to look up the nzb in history
|
# try to look up the nzb in history
|
||||||
@ -600,6 +613,7 @@ class PostProcessor(object):
|
|||||||
showObj = helpers.findCertainShow(sickbeard.showList, indexer_id)
|
showObj = helpers.findCertainShow(sickbeard.showList, indexer_id)
|
||||||
if(showObj != None):
|
if(showObj != None):
|
||||||
indexer_lang = showObj.lang
|
indexer_lang = showObj.lang
|
||||||
|
indexer = 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
|
||||||
|
|
||||||
@ -622,7 +636,7 @@ class PostProcessor(object):
|
|||||||
episodes = []
|
episodes = []
|
||||||
continue
|
continue
|
||||||
except indexer_exceptions.indexer_error, e:
|
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 = []
|
episodes = []
|
||||||
continue
|
continue
|
||||||
|
|
||||||
@ -635,9 +649,9 @@ class PostProcessor(object):
|
|||||||
season = 1
|
season = 1
|
||||||
|
|
||||||
if indexer_id and season != None and episodes:
|
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):
|
def _get_ep_obj(self, indexer_id, season, episodes):
|
||||||
"""
|
"""
|
||||||
@ -813,11 +827,11 @@ class PostProcessor(object):
|
|||||||
self.in_history = False
|
self.in_history = False
|
||||||
|
|
||||||
# try to find the file info
|
# 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 we don't have it then give up
|
||||||
if not indexer_id or season == None or not episodes:
|
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
|
return False
|
||||||
|
|
||||||
# retrieve/create the corresponding TVEpisode objects
|
# retrieve/create the corresponding TVEpisode objects
|
||||||
|
@ -272,8 +272,8 @@ class TVCache():
|
|||||||
logger.log(u"Trying to look the show up in the show database", logger.DEBUG)
|
logger.log(u"Trying to look the show up in the show database", logger.DEBUG)
|
||||||
showResult = helpers.searchDBForShow(parse_result.series_name)
|
showResult = helpers.searchDBForShow(parse_result.series_name)
|
||||||
if showResult:
|
if showResult:
|
||||||
logger.log(parse_result.series_name + " was found to be show " + showResult[1] + " ("+str(showResult[0])+") in our DB.", logger.DEBUG)
|
logger.log(parse_result.series_name + " was found to be show " + showResult[2] + " ("+str(showResult[1])+") in our DB.", logger.DEBUG)
|
||||||
indexer_id = showResult[0]
|
indexer_id = showResult[1]
|
||||||
|
|
||||||
# if the DB lookup fails then do a comprehensive regex search
|
# if the DB lookup fails then do a comprehensive regex search
|
||||||
if indexer_id == None:
|
if indexer_id == None:
|
||||||
|
Loading…
Reference in New Issue
Block a user