mirror of
https://github.com/clinton-hall/nzbToMedia.git
synced 2025-08-21 05:43:16 -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)
|
return clean_directory(path, files)
|
||||||
|
|
||||||
|
|
||||||
def get_dirs(section, subsection, link='hard'):
|
def process_dir(path, link):
|
||||||
to_return = []
|
|
||||||
|
|
||||||
def process_dir(path):
|
|
||||||
folders = []
|
folders = []
|
||||||
|
|
||||||
logger.info('Searching {0} for mediafiles to post-process ...'.format(path))
|
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])
|
folders.extend([directory])
|
||||||
return folders
|
return folders
|
||||||
|
|
||||||
|
|
||||||
|
def get_dirs(section, subsection, link='hard'):
|
||||||
|
to_return = []
|
||||||
|
|
||||||
try:
|
try:
|
||||||
watch_dir = os.path.join(core.CFG[section][subsection]['watch_dir'], subsection)
|
watch_dir = os.path.join(core.CFG[section][subsection]['watch_dir'], subsection)
|
||||||
if os.path.exists(watch_dir):
|
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']):
|
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:
|
except Exception as e:
|
||||||
logger.error('Failed to add directories from {0} for post-processing: {1}'.format
|
logger.error('Failed to add directories from {0} for post-processing: {1}'.format
|
||||||
(core.CFG[section][subsection]['watch_dir'], e))
|
(core.CFG[section][subsection]['watch_dir'], e))
|
||||||
|
@ -175,7 +176,7 @@ def get_dirs(section, subsection, link='hard'):
|
||||||
try:
|
try:
|
||||||
output_directory = os.path.join(core.OUTPUTDIRECTORY, subsection)
|
output_directory = os.path.join(core.OUTPUTDIRECTORY, subsection)
|
||||||
if os.path.exists(output_directory):
|
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:
|
except Exception as e:
|
||||||
logger.error('Failed to add directories from {0} for post-processing: {1}'.format(core.OUTPUTDIRECTORY, 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