mirror of
https://github.com/clinton-hall/nzbToMedia.git
synced 2025-08-20 21:33:13 -07:00
Flatten get_dirs function
This commit is contained in:
parent
03cb11dae3
commit
e67f29cb7b
1 changed files with 83 additions and 82 deletions
|
@ -79,10 +79,7 @@ def clean_dir(path, section, subsection):
|
|||
return clean_directory(path, files)
|
||||
|
||||
|
||||
def get_dirs(section, subsection, link='hard'):
|
||||
to_return = []
|
||||
|
||||
def process_dir(path):
|
||||
def process_dir(path, link):
|
||||
folders = []
|
||||
|
||||
logger.info('Searching {0} for mediafiles to post-process ...'.format(path))
|
||||
|
@ -161,12 +158,16 @@ def get_dirs(section, subsection, link='hard'):
|
|||
folders.extend([directory])
|
||||
return folders
|
||||
|
||||
|
||||
def get_dirs(section, subsection, link='hard'):
|
||||
to_return = []
|
||||
|
||||
try:
|
||||
watch_dir = os.path.join(core.CFG[section][subsection]['watch_dir'], subsection)
|
||||
if os.path.exists(watch_dir):
|
||||
to_return.extend(process_dir(watch_dir))
|
||||
to_return.extend(process_dir(watch_dir, link))
|
||||
elif os.path.exists(core.CFG[section][subsection]['watch_dir']):
|
||||
to_return.extend(process_dir(core.CFG[section][subsection]['watch_dir']))
|
||||
to_return.extend(process_dir(core.CFG[section][subsection]['watch_dir'], link))
|
||||
except Exception as e:
|
||||
logger.error('Failed to add directories from {0} for post-processing: {1}'.format
|
||||
(core.CFG[section][subsection]['watch_dir'], e))
|
||||
|
@ -175,7 +176,7 @@ def get_dirs(section, subsection, link='hard'):
|
|||
try:
|
||||
output_directory = os.path.join(core.OUTPUTDIRECTORY, subsection)
|
||||
if os.path.exists(output_directory):
|
||||
to_return.extend(process_dir(output_directory))
|
||||
to_return.extend(process_dir(output_directory, link))
|
||||
except Exception as e:
|
||||
logger.error('Failed to add directories from {0} for post-processing: {1}'.format(core.OUTPUTDIRECTORY, e))
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue