|
|
@ -207,6 +207,22 @@ class ProcessTVShow(object): |
|
|
|
|
|
|
|
return None |
|
|
|
|
|
|
|
@staticmethod |
|
|
|
def find_parent(path): |
|
|
|
""" |
|
|
|
Test path is inside a parent folder |
|
|
|
|
|
|
|
:param path: Path to check |
|
|
|
:type path: String |
|
|
|
:return: Parent root dir that matches path, or None |
|
|
|
:rtype: String, None |
|
|
|
""" |
|
|
|
process_path = ek.ek(os.path.realpath, ek.ek(os.path.expanduser, path.lower())) |
|
|
|
# sort paths by longest to test path containing "abc123" before "abc" |
|
|
|
for parent in sorted(sickbeard.ROOT_DIRS.split('|')[1:], reverse=True): |
|
|
|
if process_path.startswith(ek.ek(os.path.realpath, ek.ek(os.path.expanduser, parent.lower()))): |
|
|
|
return parent |
|
|
|
|
|
|
|
def process_dir(self, dir_name, nzb_name=None, process_method=None, force=False, force_replace=None, |
|
|
|
failed=False, pp_type='auto', cleanup=False, showObj=None): |
|
|
|
""" |
|
|
@ -243,10 +259,10 @@ class ProcessTVShow(object): |
|
|
|
u'you fill out your completed TV download folder in the PP config.') |
|
|
|
return self.result |
|
|
|
|
|
|
|
for path in sickbeard.ROOT_DIRS.split('|')[1:]: |
|
|
|
if dir_name.startswith(ek.ek(os.path.realpath, path)): |
|
|
|
self._log_helper('Dir is subdir of show root dir: %s, not processing.' % path) |
|
|
|
return self.result |
|
|
|
parent = self.find_parent(dir_name) |
|
|
|
if parent: |
|
|
|
self._log_helper('Dir is subdir of show root dir: %s, not processing.' % parent) |
|
|
|
return self.result |
|
|
|
|
|
|
|
if dir_name == sickbeard.TV_DOWNLOAD_DIR: |
|
|
|
self.is_basedir = True |
|
|
@ -337,7 +353,6 @@ class ProcessTVShow(object): |
|
|
|
(ex(e), e.filename and (' (file %s)' % e.filename) or ''), logger.WARNING) |
|
|
|
|
|
|
|
# Process video files in TV subdirectories |
|
|
|
root_show_dirs = [ek.ek(os.path.realpath, rp) for rp in sickbeard.ROOT_DIRS.split('|')[1:]] |
|
|
|
for directory in [x for x in dirs if self._validate_dir( |
|
|
|
path, x, nzb_name_original, failed, |
|
|
|
showObj=self.showObj_helper(showObj, dir_name, x, nzb_name, pp_type))]: |
|
|
@ -350,13 +365,9 @@ class ProcessTVShow(object): |
|
|
|
self._log_helper(u'Found temporary sync files, skipping post process', logger.ERROR) |
|
|
|
return self.result |
|
|
|
|
|
|
|
is_sub = False |
|
|
|
for r_path in root_show_dirs: |
|
|
|
if walk_path.startswith(ek.ek(os.path.realpath, r_path)): |
|
|
|
self._log_helper('Dir is subdir of show root dir: %s, not processing.' % r_path) |
|
|
|
is_sub = True |
|
|
|
break |
|
|
|
if is_sub: |
|
|
|
parent = self.find_parent(walk_path) |
|
|
|
if parent: |
|
|
|
self._log_helper('Dir is subdir of show root dir: %s, not processing files.' % parent) |
|
|
|
continue |
|
|
|
|
|
|
|
# Ignore any symlinks at this stage to avoid the potential for unraring a symlinked archive |
|
|
@ -865,7 +876,6 @@ class ProcessTVShow(object): |
|
|
|
use_trash=False, showObj=None): |
|
|
|
|
|
|
|
processor = None |
|
|
|
root_show_dirs = [ek.ek(os.path.realpath, rp) for rp in sickbeard.ROOT_DIRS.split('|')[1:]] |
|
|
|
for cur_video_file in video_files: |
|
|
|
|
|
|
|
if self._already_postprocessed(process_path, cur_video_file, force): |
|
|
@ -874,13 +884,9 @@ class ProcessTVShow(object): |
|
|
|
|
|
|
|
cur_video_file_path = ek.ek(os.path.join, process_path, cur_video_file) |
|
|
|
|
|
|
|
is_sub = False |
|
|
|
for r_path in root_show_dirs: |
|
|
|
if cur_video_file_path.startswith(r_path): |
|
|
|
self._log_helper('Dir is subdir of show root dir: %s, not processing.' % r_path) |
|
|
|
is_sub = True |
|
|
|
break |
|
|
|
if is_sub: |
|
|
|
parent = self.find_parent(cur_video_file_path) |
|
|
|
if parent: |
|
|
|
self._log_helper('Dir is subdir of show root dir: %s, not processing media.' % parent) |
|
|
|
continue |
|
|
|
|
|
|
|
try: |
|
|
|