Merge pull request #993 from JackDandy/feature/ChangeAddFilenameHistoryLookup

Add file_name to possible names in history lookup post processing.
This commit is contained in:
JackDandy 2017-10-25 04:43:11 +01:00 committed by GitHub
commit 04f919f15e
8 changed files with 34 additions and 9 deletions

View file

@ -115,6 +115,8 @@
* Change improve handling of relative download links from providers
* Change enable TorrentBytes provider
* Change after SG is updated, don't attempt to send a Plex client notifications if there is no client host set
* Add file name to possible names in history lookup post processing
* Add garbage name handling to name parser
[develop changelog]

View file

@ -109,6 +109,8 @@ def processEpisode(dir_to_process, org_NZB_name=None, status=None):
params = {}
params['is_basedir'] = 0
params['quiet'] = 1
params['dir'] = dir_to_process

View file

@ -43,6 +43,6 @@ class PostProcesser():
'(and probably not what you really want to process)' % sickbeard.TV_DOWNLOAD_DIR, logger.ERROR)
return
processTV.processDir(sickbeard.TV_DOWNLOAD_DIR)
processTV.processDir(sickbeard.TV_DOWNLOAD_DIR, is_basedir=True)
self.amActive = False

View file

@ -115,6 +115,9 @@ class NameParser(object):
if not match:
continue
if 'garbage_name' == cur_regex_name:
return
result = ParseResult(new_name)
result.which_regex = [cur_regex_name]
result.score = 0 - cur_regex_num

View file

@ -19,6 +19,11 @@
# all regexes are case insensitive
normal_regexes = [
('garbage_name',
'''
^[a-zA-Z0-9]{3,}$
'''
),
('standard_repeat',
# Show.Name.S01E02.S01E03.Source.Quality.Etc-Group
# Show Name - S01E02 - S01E03 - S01E04 - Ep Name

View file

@ -417,7 +417,7 @@ class PostProcessor(object):
self.in_history = False
# if we don't have either of these then there's nothing to use to search the history for anyway
if not self.nzb_name and not self.folder_name:
if not self.nzb_name and not self.file_name and not self.folder_name:
return to_return
# make a list of possible names to use in the search
@ -426,6 +426,10 @@ class PostProcessor(object):
names.append(self.nzb_name)
if '.' in self.nzb_name:
names.append(self.nzb_name.rpartition('.')[0])
if self.file_name:
names.append(self.file_name)
if '.' in self.file_name:
names.append(self.file_name.rpartition('.')[0])
if self.folder_name:
names.append(self.folder_name)

View file

@ -58,12 +58,13 @@ except ImportError:
class ProcessTVShow(object):
""" Process a TV Show """
def __init__(self, webhandler=None):
def __init__(self, webhandler=None, is_basedir=True):
self.files_passed = 0
self.files_failed = 0
self.fail_detected = False
self._output = []
self.webhandler = webhandler
self.is_basedir = is_basedir
@property
def any_vid_processed(self):
@ -163,8 +164,10 @@ class ProcessTVShow(object):
return result
@staticmethod
def check_name(name):
def check_name(self, name):
if self.is_basedir:
return None
so = None
my_db = db.DBConnection()
sql_results = my_db.select(
@ -189,6 +192,9 @@ class ProcessTVShow(object):
return (showObj, alt_showObj)[None is showObj and None is not alt_showObj]
def check_video_filenames(self, path, videofiles):
if self.is_basedir:
return None
video_pick = None
video_size = 0
for cur_video_file in videofiles:
@ -247,6 +253,9 @@ class ProcessTVShow(object):
u'you fill out your completed TV download folder in the PP config.')
return self.result
if dir_name == sickbeard.TV_DOWNLOAD_DIR:
self.is_basedir = True
if None is showObj:
if isinstance(nzb_name, basestring):
showObj = self.check_name(re.sub(r'\.(nzb|torrent)$', '', nzb_name, flags=re.I))
@ -939,8 +948,8 @@ class ProcessTVShow(object):
# backward compatibility prevents the case of this function name from being updated to PEP8
def processDir(dir_name, nzb_name=None, process_method=None, force=False, force_replace=None,
failed=False, type='auto', cleanup=False, webhandler=None, showObj=None):
failed=False, type='auto', cleanup=False, webhandler=None, showObj=None, is_basedir=True):
# backward compatibility prevents the case of this function name from being updated to PEP8
return ProcessTVShow(webhandler).process_dir(
return ProcessTVShow(webhandler, is_basedir).process_dir(
dir_name, nzb_name, process_method, force, force_replace, failed, type, cleanup, showObj)

View file

@ -2558,7 +2558,7 @@ class HomePostProcess(Home):
return t.respond()
def processEpisode(self, dir=None, nzbName=None, jobName=None, quiet=None, process_method=None, force=None,
force_replace=None, failed='0', type='auto', stream='0', dupekey=None, **kwargs):
force_replace=None, failed='0', type='auto', stream='0', dupekey=None, is_basedir='1', **kwargs):
if not dir and ('0' == failed or not nzbName):
self.redirect('/home/postprocess/')
@ -2582,7 +2582,7 @@ class HomePostProcess(Home):
force_replace=force_replace in ['on', '1'],
failed='0' != failed,
webhandler=self.send_message if stream != '0' else None,
showObj=showObj)
showObj=showObj, is_basedir=is_basedir in ['on', '1'])
if '0' != stream:
return