mirror of
https://github.com/SickGear/SickGear.git
synced 2025-03-15 09:07:43 +00:00
Post-processing now auto-detects the correct indexer for the show both on manual processing and script based processing
This commit is contained in:
parent
b8048a7e57
commit
22a4a066d8
6 changed files with 45 additions and 76 deletions
|
@ -15,13 +15,6 @@
|
||||||
<form name="processForm" method="post" action="processEpisode" style="line-height: 44px">
|
<form name="processForm" method="post" action="processEpisode" style="line-height: 44px">
|
||||||
<input type="hidden" id="type" name="type" value="manual">
|
<input type="hidden" id="type" name="type" value="manual">
|
||||||
<b>Enter the folder containing the episode:</b> <input type="text" name="dir" id="episodeDir" size="50" /><br/>
|
<b>Enter the folder containing the episode:</b> <input type="text" name="dir" id="episodeDir" size="50" /><br/>
|
||||||
<b>Show Indexer to be used:</b>
|
|
||||||
<select name="indexer" id="indexer" class="indexer">
|
|
||||||
#for $curIndexer in sorted($sickbeard.indexerApi().indexers.items(), key=lambda x: x[1]):
|
|
||||||
<option value="$curIndexer[0]" #if $curIndexer[0] in $sickbeard.indexerApi().indexers then "selected=\"selected\"" else ""#>$curIndexer[1]</option>
|
|
||||||
#end for
|
|
||||||
</select>
|
|
||||||
<br/>
|
|
||||||
<b>Process Method to be used:</b>
|
<b>Process Method to be used:</b>
|
||||||
<select name="process_method" id="process_method" class="input-medium" >
|
<select name="process_method" id="process_method" class="input-medium" >
|
||||||
#set $process_method_text = {'copy': "Copy", 'move': "Move", 'hardlink': "Hard Link", 'symlink' : "Symbolic Link"}
|
#set $process_method_text = {'copy': "Copy", 'move': "Move", 'hardlink': "Hard Link", 'symlink' : "Symbolic Link"}
|
||||||
|
|
|
@ -300,11 +300,17 @@ def searchDBForShow(regShowName, indexer_id=None):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
def searchIndexersForShow(regShowName, indexer_id=None):
|
def searchIndexersForShow(regShowName, indexer=None, 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 sickbeard.indexerApi().indexers:
|
for indexer in indexers:
|
||||||
def searchShows():
|
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
|
||||||
|
|
|
@ -101,11 +101,11 @@ ep_regexes = [
|
||||||
# Show Name - 2010-Nov-23rd - Ep Name
|
# Show Name - 2010-Nov-23rd - Ep Name
|
||||||
'''
|
'''
|
||||||
^(?P<series_name>.*?(UEFA|MLB|ESPN|WWE|MMA|UFC|TNA|EPL|NASCAR|NBA|NFL|NHL|NRL|PGA|SUPER LEAGUE|FORMULA|FIFA|NETBALL|MOTOGP).*?)
|
^(?P<series_name>.*?(UEFA|MLB|ESPN|WWE|MMA|UFC|TNA|EPL|NASCAR|NBA|NFL|NHL|NRL|PGA|SUPER LEAGUE|FORMULA|FIFA|NETBALL|MOTOGP).*?)
|
||||||
(?P<air_day>\d{1,2}[a-zA-Z]{2})[. _-]+ # 23rd and seperator
|
(?P<air_day>\d{1,2}[a-zA-Z]{2})[. _-]+ # 23rd and seperator
|
||||||
(?P<air_month>[a-zA-Z]{3,})[. _-]+ # Nov and seperator
|
(?P<air_month>[a-zA-Z]{3,})[. _-]+ # Nov and seperator
|
||||||
(?P<air_year>\d{4})[. _-]+ # 2010
|
(?P<air_year>\d{4})[. _-]+ # 2010
|
||||||
(?P<extra_info>.*?(?<![. _-])(?<!WEB))[. _-]+ # Make sure this is really the release group
|
(?P<extra_info>.*?(?<![. _-])(?<!WEB))[. _-]+ # Make sure this is really the release group
|
||||||
(?P<release_group>.*?)$ # Group
|
(?P<release_group>.*?)$ # Group
|
||||||
'''),
|
'''),
|
||||||
|
|
||||||
('stupid',
|
('stupid',
|
||||||
|
|
|
@ -63,7 +63,7 @@ class PostProcessor(object):
|
||||||
FOLDER_NAME = 2
|
FOLDER_NAME = 2
|
||||||
FILE_NAME = 3
|
FILE_NAME = 3
|
||||||
|
|
||||||
def __init__(self, file_path, nzb_name=None, process_method=None, is_priority=None, indexer=None):
|
def __init__(self, file_path, nzb_name=None, process_method=None, is_priority=None):
|
||||||
"""
|
"""
|
||||||
Creates a new post processor with the given file path and optionally an NZB name.
|
Creates a new post processor with the given file path and optionally an NZB name.
|
||||||
|
|
||||||
|
@ -93,7 +93,7 @@ class PostProcessor(object):
|
||||||
|
|
||||||
self.is_priority = is_priority
|
self.is_priority = is_priority
|
||||||
|
|
||||||
self.indexer = indexer
|
self.indexer = None
|
||||||
|
|
||||||
self.good_results = {self.NZB_NAME: False,
|
self.good_results = {self.NZB_NAME: False,
|
||||||
self.FOLDER_NAME: False,
|
self.FOLDER_NAME: False,
|
||||||
|
@ -522,43 +522,20 @@ class PostProcessor(object):
|
||||||
_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 with a TVDB lookup
|
# see if we can find the name on the Indexer
|
||||||
for cur_name in name_list:
|
for cur_name in name_list:
|
||||||
try:
|
foundInfo = helpers.searchIndexersForShow(cur_name, indexer=self.indexer)
|
||||||
lINDEXER_API_PARMS = {'indexer': self.indexer}
|
|
||||||
|
|
||||||
lINDEXER_API_PARMS['custom_ui'] = classes.ShowListUI
|
if foundInfo:
|
||||||
|
indexer_id = foundInfo[1]
|
||||||
|
|
||||||
t = sickbeard.indexerApi(**lINDEXER_API_PARMS)
|
self._log(
|
||||||
|
u"Lookup successful, using " + sickbeard.indexerApi(self.indexer).name + " id " + str(indexer_id),
|
||||||
|
logger.DEBUG)
|
||||||
|
|
||||||
self._log(u"Looking up name " + cur_name + u" on " + sickbeard.indexerApi(self.indexer).name + "",
|
# return found results
|
||||||
logger.DEBUG)
|
_finalize(parse_result)
|
||||||
showObj = t[cur_name]
|
return (indexer_id, season, episodes)
|
||||||
except (sickbeard.indexer_exception, IOError):
|
|
||||||
# if none found, search on all languages
|
|
||||||
try:
|
|
||||||
lINDEXER_API_PARMS = {'indexer': self.indexer}
|
|
||||||
|
|
||||||
lINDEXER_API_PARMS['search_all_languages'] = True
|
|
||||||
lINDEXER_API_PARMS['custom_ui'] = classes.ShowListUI
|
|
||||||
|
|
||||||
t = sickbeard.indexerApi(**lINDEXER_API_PARMS)
|
|
||||||
|
|
||||||
self._log(u"Looking up name " + cur_name + u" in all languages on " + sickbeard.indexerApi(
|
|
||||||
self.indexer).name + "", logger.DEBUG)
|
|
||||||
showObj = t[cur_name]
|
|
||||||
except (sickbeard.indexer_exception, IOError):
|
|
||||||
pass
|
|
||||||
|
|
||||||
continue
|
|
||||||
except (IOError):
|
|
||||||
continue
|
|
||||||
|
|
||||||
self._log(
|
|
||||||
u"Lookup successful, using " + sickbeard.indexerApi(self.indexer).name + " id " + str(showObj["id"]),
|
|
||||||
logger.DEBUG)
|
|
||||||
_finalize(parse_result)
|
|
||||||
return (int(showObj["id"]), season, episodes)
|
|
||||||
|
|
||||||
_finalize(parse_result)
|
_finalize(parse_result)
|
||||||
return to_return
|
return to_return
|
||||||
|
@ -620,7 +597,7 @@ 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 = showObj.indexer
|
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
|
||||||
|
|
||||||
|
@ -857,22 +834,17 @@ class PostProcessor(object):
|
||||||
|
|
||||||
# try to find the file info
|
# try to find the file info
|
||||||
indexer_id = season = episodes = None
|
indexer_id = season = episodes = None
|
||||||
if 'auto' in self.indexer:
|
for indexer in sickbeard.indexerApi().indexers:
|
||||||
for indexer in sickbeard.indexerApi().indexers:
|
self.indexer = int(indexer)
|
||||||
self.indexer = indexer
|
|
||||||
|
|
||||||
# try to find the file info
|
# 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 " + sickbeard.indexerApi(
|
|
||||||
self.indexer).name + ", auto trying next indexer in list", logger.WARNING)
|
|
||||||
else:
|
|
||||||
(indexer_id, season, episodes) = self._find_info()
|
(indexer_id, season, episodes) = self._find_info()
|
||||||
|
if indexer_id and season != None and episodes:
|
||||||
|
break
|
||||||
|
|
||||||
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 ANY of the indexers or season or episode, skipping", logger.WARNING)
|
self._log(u"Can't find thhe show on any of the Indexers, skipping",
|
||||||
|
logger.WARNING)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
# retrieve/create the corresponding TVEpisode objects
|
# retrieve/create the corresponding TVEpisode objects
|
||||||
|
|
|
@ -42,8 +42,7 @@ def logHelper(logMessage, logLevel=logger.MESSAGE):
|
||||||
return logMessage + u"\n"
|
return logMessage + u"\n"
|
||||||
|
|
||||||
|
|
||||||
def processDir(dirName, nzbName=None, process_method=None, force=False, is_priority=None, failed=False, type="auto",
|
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
|
Scans through the files in dirName and processes whatever media files it finds
|
||||||
|
|
||||||
|
@ -52,7 +51,6 @@ def processDir(dirName, nzbName=None, process_method=None, force=False, is_prior
|
||||||
force: True to postprocess already postprocessed files
|
force: True to postprocess already postprocessed files
|
||||||
failed: Boolean for whether or not the download failed
|
failed: Boolean for whether or not the download failed
|
||||||
type: Type of postprocessing auto or manual
|
type: Type of postprocessing auto or manual
|
||||||
indexer: Indexer for show can be Tvdb or TVRage or auto to auto-discover
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
global process_result, returnStr
|
global process_result, returnStr
|
||||||
|
@ -108,13 +106,13 @@ def processDir(dirName, nzbName=None, process_method=None, force=False, is_prior
|
||||||
|
|
||||||
#Don't Link media when the media is extracted from a rar in the same path
|
#Don't Link media when the media is extracted from a rar in the same path
|
||||||
if process_method in ('hardlink', 'symlink') and videoInRar:
|
if process_method in ('hardlink', 'symlink') and videoInRar:
|
||||||
process_media(path, videoInRar, nzbName, 'move', force, is_priority, indexer)
|
process_media(path, videoInRar, nzbName, 'move', force, is_priority)
|
||||||
delete_files(path, rarContent)
|
delete_files(path, rarContent)
|
||||||
for video in set(videoFiles) - set(videoInRar):
|
for video in set(videoFiles) - set(videoInRar):
|
||||||
process_media(path, [video], nzbName, process_method, force, is_priority, indexer)
|
process_media(path, [video], nzbName, process_method, force, is_priority)
|
||||||
else:
|
else:
|
||||||
for video in videoFiles:
|
for video in videoFiles:
|
||||||
process_media(path, [video], nzbName, process_method, force, is_priority, indexer)
|
process_media(path, [video], nzbName, process_method, force, is_priority)
|
||||||
|
|
||||||
#Process Video File in all TV Subdir
|
#Process Video File in all TV Subdir
|
||||||
for dir in [x for x in dirs if validateDir(path, x, nzbNameOriginal, failed)]:
|
for dir in [x for x in dirs if validateDir(path, x, nzbNameOriginal, failed)]:
|
||||||
|
@ -132,12 +130,12 @@ def processDir(dirName, nzbName=None, process_method=None, force=False, is_prior
|
||||||
|
|
||||||
#Don't Link media when the media is extracted from a rar in the same path
|
#Don't Link media when the media is extracted from a rar in the same path
|
||||||
if process_method in ('hardlink', 'symlink') and videoInRar:
|
if process_method in ('hardlink', 'symlink') and videoInRar:
|
||||||
process_media(processPath, videoInRar, nzbName, 'move', force, is_priority, indexer)
|
process_media(processPath, videoInRar, nzbName, 'move', force, is_priority)
|
||||||
process_media(processPath, set(videoFiles) - set(videoInRar), nzbName, process_method, force,
|
process_media(processPath, set(videoFiles) - set(videoInRar), nzbName, process_method, force,
|
||||||
is_priority, indexer)
|
is_priority)
|
||||||
delete_files(processPath, rarContent)
|
delete_files(processPath, rarContent)
|
||||||
else:
|
else:
|
||||||
process_media(processPath, videoFiles, nzbName, process_method, force, is_priority, indexer)
|
process_media(processPath, videoFiles, nzbName, process_method, force, is_priority)
|
||||||
|
|
||||||
#Delete all file not needed
|
#Delete all file not needed
|
||||||
if process_method != "move" or not process_result \
|
if process_method != "move" or not process_result \
|
||||||
|
@ -309,7 +307,7 @@ def already_postprocessed(dirName, videofile, force):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
def process_media(processPath, videoFiles, nzbName, process_method, force, is_priority, indexer):
|
def process_media(processPath, videoFiles, nzbName, process_method, force, is_priority):
|
||||||
global process_result, returnStr
|
global process_result, returnStr
|
||||||
|
|
||||||
for cur_video_file in videoFiles:
|
for cur_video_file in videoFiles:
|
||||||
|
@ -320,7 +318,7 @@ def process_media(processPath, videoFiles, nzbName, process_method, force, is_pr
|
||||||
cur_video_file_path = ek.ek(os.path.join, processPath, cur_video_file)
|
cur_video_file_path = ek.ek(os.path.join, processPath, cur_video_file)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
processor = postProcessor.PostProcessor(cur_video_file_path, nzbName, process_method, is_priority, indexer)
|
processor = postProcessor.PostProcessor(cur_video_file_path, nzbName, process_method, is_priority)
|
||||||
process_result = processor.process()
|
process_result = processor.process()
|
||||||
process_fail_message = ""
|
process_fail_message = ""
|
||||||
except exceptions.PostProcessingFailed, e:
|
except exceptions.PostProcessingFailed, e:
|
||||||
|
|
|
@ -1905,7 +1905,7 @@ class HomePostProcess:
|
||||||
|
|
||||||
@cherrypy.expose
|
@cherrypy.expose
|
||||||
def processEpisode(self, dir=None, dirName=None, nzbName=None, jobName=None, quiet=None, process_method=None,
|
def processEpisode(self, dir=None, dirName=None, nzbName=None, jobName=None, quiet=None, process_method=None,
|
||||||
force=None, is_priority=None, failed="0", type="auto", indexer="auto"):
|
force=None, is_priority=None, failed="0", type="auto"):
|
||||||
|
|
||||||
# auto-detect dirParam style
|
# auto-detect dirParam style
|
||||||
dirParam = dir if dir is not None else dirName if not None else redirect("/home/postprocess/")
|
dirParam = dir if dir is not None else dirName if not None else redirect("/home/postprocess/")
|
||||||
|
@ -1926,7 +1926,7 @@ class HomePostProcess:
|
||||||
is_priority = False
|
is_priority = False
|
||||||
|
|
||||||
result = processTV.processDir(dirParam, nzbName, process_method=process_method, force=force,
|
result = processTV.processDir(dirParam, nzbName, process_method=process_method, force=force,
|
||||||
is_priority=is_priority, failed=failed, type=type, indexer=indexer)
|
is_priority=is_priority, failed=failed, type=type)
|
||||||
if quiet is not None and int(quiet) == 1:
|
if quiet is not None and int(quiet) == 1:
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
@ -2068,7 +2068,7 @@ 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)
|
found_info = helpers.searchIndexersForShow(show_name, indexer_id=indexer_id)
|
||||||
|
|
||||||
if found_info:
|
if found_info:
|
||||||
# set indexer and indexer_id from found info
|
# set indexer and indexer_id from found info
|
||||||
|
|
Loading…
Reference in a new issue