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

Updates to auto post-processing code, additional code added to ensure indexer is always set to the correct value

This commit is contained in:
echel0n 2014-03-10 13:31:41 -07:00
parent fddee6d687
commit 6a4adceb26
6 changed files with 38 additions and 38 deletions

View File

@ -25,6 +25,10 @@ import regexes
import sickbeard
from sickbeard import logger
from sickbeard import classes
from sickbeard import show_name_helpers
from sickbeard import scene_numbering
from sickbeard import scene_exceptions
from sickbeard.indexers import indexer_api, indexer_exceptions

View File

@ -46,8 +46,8 @@ from sickbeard.exceptions import ex
from sickbeard.name_parser.parser import NameParser, InvalidNameException
from sickbeard.indexers import indexer_api, indexer_exceptions
from common import indexerStrings
class PostProcessor(object):
"""
@ -510,7 +510,7 @@ 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 " + db_result[0] + " id " + str(db_result[0]), logger.DEBUG)
self._log(u"Lookup successful, using " + db_result[0] + " id " + str(db_result[1]), logger.DEBUG)
_finalize(parse_result)
return (int(db_result[1]), season, episodes)
@ -808,11 +808,6 @@ class PostProcessor(object):
Post-process a given file
"""
if self.indexer is not None:
sickbeard.INDEXER_API_PARMS['indexer'] = self.indexer
else:
sickbeard.INDEXER_API_PARMS['indexer'] = 'Tvdb'
self._log(u"Processing " + self.file_path + " (" + str(self.nzb_name) + ")")
if ek.ek(os.path.isdir, self.file_path):
@ -825,26 +820,27 @@ class PostProcessor(object):
# reset per-file stuff
self.in_history = False
# try to find the file info
(indexer_id, season, episodes) = self._find_info()
indexer_id = season = episodes = None
if 'auto' in self.indexer:
for indexer in indexerStrings:
self.indexer = indexer[0]
sickbeard.INDEXER_API_PARMS['indexer'] = self.indexer
# if we don't have it then give up
if not indexer_id or season == None or not episodes:
if 'Tvdb' in self.indexer:
self._log(u"Can't find show id from " + self.indexer + " or season or episode, trying other indexer", logger.WARNING)
self.indexer = 'TVRage'
else:
self._log(u"Can't find show id from " + self.indexer + " or season or episode, trying other indexer", logger.WARNING)
self.indexer = 'Tvdb'
# try to find the file info
(indexer_id, season, episodes) = self._find_info()
if indexer_id and season != None and episodes:
break
self._log(u"Can't find show on " + self.indexer + ", auto trying next indexer in list", logger.WARNING)
else:
sickbeard.INDEXER_API_PARMS['indexer'] = self.indexer
# try to find the file info with a different indexer
# try to find the file info
(indexer_id, season, episodes) = self._find_info()
if not indexer_id or season == None or not episodes:
self._log(u"Can't find show id from ANY of the indexers or season or episode, skipping", logger.WARNING)
return False
if not indexer_id or season == None or not episodes:
self._log(u"Can't find show id from ANY of the indexers or season or episode, skipping", logger.WARNING)
return False
# retrieve/create the corresponding TVEpisode objects
ep_obj = self._get_ep_obj(indexer_id, season, episodes)

View File

@ -40,7 +40,7 @@ def logHelper (logMessage, logLevel=logger.MESSAGE):
logger.log(logMessage, logLevel)
return logMessage + u"\n"
def processDir(dirName, nzbName=None, process_method=None, force=False, is_priority=None, failed=False, type="auto", indexer="Tvdb"):
def processDir(dirName, nzbName=None, process_method=None, force=False, is_priority=None, failed=False, type="auto", indexer="auto"):
"""
Scans through the files in dirName and processes whatever media files it finds

View File

@ -167,6 +167,10 @@ class ProperFinder():
logger.log(u"This should never have happened, post a bug about this!", logger.ERROR)
raise Exception("BAD STUFF HAPPENED")
# correct the indexer with the proper one linked to the show
self.indexer = showObj.indexer
sickbeard.INDEXER_API_PARMS['indexer'] = self.indexer
indexer_lang = showObj.lang
# There's gotta be a better way of doing this but we don't wanna
# change the language value elsewhere

View File

@ -225,7 +225,7 @@ class TVCache():
indexer_lang = None
# if we need indexer_id or tvrage_id then search the DB for them
if not indexer_id or not tvrage_id:
if not indexer_id:
# if we have only the indexer_id, use the database
if indexer_id:
@ -234,23 +234,11 @@ class TVCache():
except (MultipleShowObjectsException):
showObj = None
if showObj:
indexer_lang = showObj.lang
else:
logger.log(u"We were given a " + self.indexer + " id " + str(indexer_id) + " but it doesn't match a show we have in our list, so leaving tvrage_id empty", logger.DEBUG)
tvrage_id = 0
# correct the indexer with the proper one linked to the show
self.indexer = showObj.indexer
sickbeard.INDEXER_API_PARMS['indexer'] = self.indexer
# if we have only a tvrage_id then use the database
elif tvrage_id:
try:
showObj = helpers.findCertainTVRageShow(sickbeard.showList, tvrage_id)
except (MultipleShowObjectsException):
showObj = None
if showObj:
indexer_id = showObj.indexerid
indexer_lang = showObj.lang
else:
logger.log(u"We were given a TVRage id " + str(tvrage_id) + " but it doesn't match a show we have in our list, so leaving indexer_id empty", logger.DEBUG)
indexer_id = 0
# if they're both empty then fill out as much info as possible by searching the show name
else:
@ -300,6 +288,10 @@ class TVCache():
except (MultipleShowObjectsException):
showObj = None
if showObj:
# correct the indexer with the proper one linked to the show
self.indexer = showObj.indexer
sickbeard.INDEXER_API_PARMS['indexer'] = self.indexer
indexer_lang = showObj.lang
# if we weren't provided with season/episode information then get it from the name that we parsed

View File

@ -2842,6 +2842,10 @@ class Home:
air_by_date = config.checkbox_to_value(air_by_date)
subtitles = config.checkbox_to_value(subtitles)
# correct the indexer with the proper one linked to the show
self.indexer = showObj.indexer
sickbeard.INDEXER_API_PARMS['indexer'] = self.indexer
indexer_lang = showObj.lang
# if we changed the language then kick off an update