|
|
@ -49,7 +49,7 @@ def make_test_case(args, npy_savename, sync_was_successful):
|
|
|
|
log_path = 'ffsubsync.log'
|
|
|
|
log_path = 'ffsubsync.log'
|
|
|
|
if args.log_dir_path and os.path.isdir(args.log_dir_path):
|
|
|
|
if args.log_dir_path and os.path.isdir(args.log_dir_path):
|
|
|
|
log_path = os.path.join(args.log_dir_path, log_path)
|
|
|
|
log_path = os.path.join(args.log_dir_path, log_path)
|
|
|
|
shutil.move(log_path, tar_dir)
|
|
|
|
shutil.copy(log_path, tar_dir)
|
|
|
|
shutil.copy(args.srtin, tar_dir)
|
|
|
|
shutil.copy(args.srtin, tar_dir)
|
|
|
|
if sync_was_successful:
|
|
|
|
if sync_was_successful:
|
|
|
|
shutil.move(args.srtout, tar_dir)
|
|
|
|
shutil.move(args.srtout, tar_dir)
|
|
|
@ -267,12 +267,14 @@ def run(args):
|
|
|
|
'when reference composed of subtitles')
|
|
|
|
'when reference composed of subtitles')
|
|
|
|
result['retval'] = 1
|
|
|
|
result['retval'] = 1
|
|
|
|
return result
|
|
|
|
return result
|
|
|
|
|
|
|
|
log_handler = None
|
|
|
|
|
|
|
|
log_path = None
|
|
|
|
if args.make_test_case:
|
|
|
|
if args.make_test_case:
|
|
|
|
log_path = 'ffsubsync.log'
|
|
|
|
log_path = 'ffsubsync.log'
|
|
|
|
if args.log_dir_path and os.path.isdir(args.log_dir_path):
|
|
|
|
if args.log_dir_path and os.path.isdir(args.log_dir_path):
|
|
|
|
log_path = os.path.join(args.log_dir_path, log_path)
|
|
|
|
log_path = os.path.join(args.log_dir_path, log_path)
|
|
|
|
handler = logging.FileHandler(log_path)
|
|
|
|
log_handler = logging.FileHandler(log_path)
|
|
|
|
logger.addHandler(handler)
|
|
|
|
logger.addHandler(log_handler)
|
|
|
|
if args.extract_subs_from_stream is not None:
|
|
|
|
if args.extract_subs_from_stream is not None:
|
|
|
|
result['retval'] = extract_subtitles_from_reference(args)
|
|
|
|
result['retval'] = extract_subtitles_from_reference(args)
|
|
|
|
return result
|
|
|
|
return result
|
|
|
@ -291,10 +293,14 @@ def run(args):
|
|
|
|
return result
|
|
|
|
return result
|
|
|
|
srt_pipes = make_srt_pipes(args)
|
|
|
|
srt_pipes = make_srt_pipes(args)
|
|
|
|
sync_was_successful = try_sync(args, reference_pipe, srt_pipes, result)
|
|
|
|
sync_was_successful = try_sync(args, reference_pipe, srt_pipes, result)
|
|
|
|
if args.make_test_case:
|
|
|
|
if log_handler is not None and log_path is not None:
|
|
|
|
handler.close()
|
|
|
|
assert args.make_test_case
|
|
|
|
logger.removeHandler(handler)
|
|
|
|
log_handler.close()
|
|
|
|
result['retval'] += make_test_case(args, npy_savename, sync_was_successful)
|
|
|
|
logger.removeHandler(log_handler)
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
|
|
|
result['retval'] += make_test_case(args, npy_savename, sync_was_successful)
|
|
|
|
|
|
|
|
finally:
|
|
|
|
|
|
|
|
os.remove(log_path)
|
|
|
|
return result
|
|
|
|
return result
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -363,7 +369,7 @@ def add_cli_only_args(parser):
|
|
|
|
help='Where to look for ffmpeg and ffprobe. Uses the system PATH by default.'
|
|
|
|
help='Where to look for ffmpeg and ffprobe. Uses the system PATH by default.'
|
|
|
|
)
|
|
|
|
)
|
|
|
|
parser.add_argument('--log-dir-path', default=None, help='Where to save ffsubsync.log file (must be an existing '
|
|
|
|
parser.add_argument('--log-dir-path', default=None, help='Where to save ffsubsync.log file (must be an existing '
|
|
|
|
'directory).')
|
|
|
|
'directory).')
|
|
|
|
parser.add_argument('--vlc-mode', action='store_true', help=argparse.SUPPRESS)
|
|
|
|
parser.add_argument('--vlc-mode', action='store_true', help=argparse.SUPPRESS)
|
|
|
|
parser.add_argument('--gui-mode', action='store_true', help=argparse.SUPPRESS)
|
|
|
|
parser.add_argument('--gui-mode', action='store_true', help=argparse.SUPPRESS)
|
|
|
|
|
|
|
|
|
|
|
|