mirror of
https://github.com/clinton-hall/nzbToMedia.git
synced 2025-07-31 03:50:06 -07:00
Fix quotes - standardize to single-quoted strings
This commit is contained in:
parent
85b4e22046
commit
c5343889fb
30 changed files with 1257 additions and 1257 deletions
|
@ -12,38 +12,38 @@ def external_script(output_destination, torrent_name, torrent_label, settings):
|
|||
final_result = 0 # start at 0.
|
||||
num_files = 0
|
||||
try:
|
||||
core.USER_SCRIPT_MEDIAEXTENSIONS = settings["user_script_mediaExtensions"].lower()
|
||||
core.USER_SCRIPT_MEDIAEXTENSIONS = settings['user_script_mediaExtensions'].lower()
|
||||
if isinstance(core.USER_SCRIPT_MEDIAEXTENSIONS, str):
|
||||
core.USER_SCRIPT_MEDIAEXTENSIONS = core.USER_SCRIPT_MEDIAEXTENSIONS.split(',')
|
||||
except Exception:
|
||||
core.USER_SCRIPT_MEDIAEXTENSIONS = []
|
||||
|
||||
core.USER_SCRIPT = settings.get("user_script_path")
|
||||
core.USER_SCRIPT = settings.get('user_script_path')
|
||||
|
||||
if not core.USER_SCRIPT or core.USER_SCRIPT == "None": # do nothing and return success.
|
||||
return [0, ""]
|
||||
if not core.USER_SCRIPT or core.USER_SCRIPT == 'None': # do nothing and return success.
|
||||
return [0, '']
|
||||
try:
|
||||
core.USER_SCRIPT_PARAM = settings["user_script_param"]
|
||||
core.USER_SCRIPT_PARAM = settings['user_script_param']
|
||||
if isinstance(core.USER_SCRIPT_PARAM, str):
|
||||
core.USER_SCRIPT_PARAM = core.USER_SCRIPT_PARAM.split(',')
|
||||
except Exception:
|
||||
core.USER_SCRIPT_PARAM = []
|
||||
try:
|
||||
core.USER_SCRIPT_SUCCESSCODES = settings["user_script_successCodes"]
|
||||
core.USER_SCRIPT_SUCCESSCODES = settings['user_script_successCodes']
|
||||
if isinstance(core.USER_SCRIPT_SUCCESSCODES, str):
|
||||
core.USER_SCRIPT_SUCCESSCODES = core.USER_SCRIPT_SUCCESSCODES.split(',')
|
||||
except Exception:
|
||||
core.USER_SCRIPT_SUCCESSCODES = 0
|
||||
|
||||
core.USER_SCRIPT_CLEAN = int(settings.get("user_script_clean", 1))
|
||||
core.USER_SCRIPT_RUNONCE = int(settings.get("user_script_runOnce", 1))
|
||||
core.USER_SCRIPT_CLEAN = int(settings.get('user_script_clean', 1))
|
||||
core.USER_SCRIPT_RUNONCE = int(settings.get('user_script_runOnce', 1))
|
||||
|
||||
if core.CHECK_MEDIA:
|
||||
for video in list_media_files(output_destination, media=True, audio=False, meta=False, archives=False):
|
||||
if transcoder.is_video_good(video, 0):
|
||||
import_subs(video)
|
||||
else:
|
||||
logger.info("Corrupt video file found {0}. Deleting.".format(video), "USERSCRIPT")
|
||||
logger.info('Corrupt video file found {0}. Deleting.'.format(video), 'USERSCRIPT')
|
||||
os.unlink(video)
|
||||
|
||||
for dirpath, dirnames, filenames in os.walk(output_destination):
|
||||
|
@ -52,25 +52,25 @@ def external_script(output_destination, torrent_name, torrent_label, settings):
|
|||
file_path = core.os.path.join(dirpath, file)
|
||||
file_name, file_extension = os.path.splitext(file)
|
||||
|
||||
if file_extension in core.USER_SCRIPT_MEDIAEXTENSIONS or "all" in core.USER_SCRIPT_MEDIAEXTENSIONS:
|
||||
if file_extension in core.USER_SCRIPT_MEDIAEXTENSIONS or 'all' in core.USER_SCRIPT_MEDIAEXTENSIONS:
|
||||
num_files += 1
|
||||
if core.USER_SCRIPT_RUNONCE == 1 and num_files > 1: # we have already run once, so just continue to get number of files.
|
||||
continue
|
||||
command = [core.USER_SCRIPT]
|
||||
for param in core.USER_SCRIPT_PARAM:
|
||||
if param == "FN":
|
||||
if param == 'FN':
|
||||
command.append('{0}'.format(file))
|
||||
continue
|
||||
elif param == "FP":
|
||||
elif param == 'FP':
|
||||
command.append('{0}'.format(file_path))
|
||||
continue
|
||||
elif param == "TN":
|
||||
elif param == 'TN':
|
||||
command.append('{0}'.format(torrent_name))
|
||||
continue
|
||||
elif param == "TL":
|
||||
elif param == 'TL':
|
||||
command.append('{0}'.format(torrent_label))
|
||||
continue
|
||||
elif param == "DN":
|
||||
elif param == 'DN':
|
||||
if core.USER_SCRIPT_RUNONCE == 1:
|
||||
command.append('{0}'.format(output_destination))
|
||||
else:
|
||||
|
@ -79,24 +79,24 @@ def external_script(output_destination, torrent_name, torrent_label, settings):
|
|||
else:
|
||||
command.append(param)
|
||||
continue
|
||||
cmd = ""
|
||||
cmd = ''
|
||||
for item in command:
|
||||
cmd = "{cmd} {item}".format(cmd=cmd, item=item)
|
||||
logger.info("Running script {cmd} on file {path}.".format(cmd=cmd, path=file_path), "USERSCRIPT")
|
||||
cmd = '{cmd} {item}'.format(cmd=cmd, item=item)
|
||||
logger.info('Running script {cmd} on file {path}.'.format(cmd=cmd, path=file_path), 'USERSCRIPT')
|
||||
try:
|
||||
p = Popen(command)
|
||||
res = p.wait()
|
||||
if str(res) in core.USER_SCRIPT_SUCCESSCODES: # Linux returns 0 for successful.
|
||||
logger.info("UserScript {0} was successfull".format(command[0]))
|
||||
logger.info('UserScript {0} was successfull'.format(command[0]))
|
||||
result = 0
|
||||
else:
|
||||
logger.error("UserScript {0} has failed with return code: {1}".format(command[0], res), "USERSCRIPT")
|
||||
logger.error('UserScript {0} has failed with return code: {1}'.format(command[0], res), 'USERSCRIPT')
|
||||
logger.info(
|
||||
"If the UserScript completed successfully you should add {0} to the user_script_successCodes".format(
|
||||
res), "USERSCRIPT")
|
||||
'If the UserScript completed successfully you should add {0} to the user_script_successCodes'.format(
|
||||
res), 'USERSCRIPT')
|
||||
result = int(1)
|
||||
except Exception:
|
||||
logger.error("UserScript {0} has failed".format(command[0]), "USERSCRIPT")
|
||||
logger.error('UserScript {0} has failed'.format(command[0]), 'USERSCRIPT')
|
||||
result = int(1)
|
||||
final_result += result
|
||||
|
||||
|
@ -105,13 +105,13 @@ def external_script(output_destination, torrent_name, torrent_label, settings):
|
|||
for file in filenames:
|
||||
file_name, file_extension = os.path.splitext(file)
|
||||
|
||||
if file_extension in core.USER_SCRIPT_MEDIAEXTENSIONS or core.USER_SCRIPT_MEDIAEXTENSIONS == "ALL":
|
||||
if file_extension in core.USER_SCRIPT_MEDIAEXTENSIONS or core.USER_SCRIPT_MEDIAEXTENSIONS == 'ALL':
|
||||
num_files_new += 1
|
||||
|
||||
if core.USER_SCRIPT_CLEAN == int(1) and num_files_new == 0 and final_result == 0:
|
||||
logger.info("All files have been processed. Cleaning outputDirectory {0}".format(output_destination))
|
||||
logger.info('All files have been processed. Cleaning outputDirectory {0}'.format(output_destination))
|
||||
remove_dir(output_destination)
|
||||
elif core.USER_SCRIPT_CLEAN == int(1) and num_files_new != 0:
|
||||
logger.info("{0} files were processed, but {1} still remain. outputDirectory will not be cleaned.".format(
|
||||
logger.info('{0} files were processed, but {1} still remain. outputDirectory will not be cleaned.'.format(
|
||||
num_files, num_files_new))
|
||||
return [final_result, '']
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue