Multiple fixes to ffsubsync.

pull/1096/head
Louis Vézina 4 years ago
parent 5dbde75893
commit 6ad4843cdf

@ -41,12 +41,15 @@ def make_test_case(args, npy_savename, sync_was_successful):
raise ValueError('need non-null npy_savename') raise ValueError('need non-null npy_savename')
tar_dir = '{}.{}'.format( tar_dir = '{}.{}'.format(
args.reference, args.reference,
datetime.now().strftime('%Y-%m-%d-%H:%M:%S') datetime.now().strftime('%Y-%m-%d-%H-%M-%S')
) )
logger.info('creating test archive {}.tar.gz...'.format(tar_dir)) logger.info('creating test archive {}.tar.gz...'.format(tar_dir))
os.mkdir(tar_dir) os.mkdir(tar_dir)
try: try:
shutil.move('ffsubsync.log', tar_dir) log_path = 'ffsubsync.log'
if args.log_dir_path and os.path.isdir(args.log_dir_path):
log_path = os.path.join(args.log_dir_path, log_path)
shutil.move(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)
@ -265,7 +268,10 @@ def run(args):
result['retval'] = 1 result['retval'] = 1
return result return result
if args.make_test_case: if args.make_test_case:
handler = logging.FileHandler('ffsubsync.log') log_path = 'ffsubsync.log'
if args.log_dir_path and os.path.isdir(args.log_dir_path):
log_path = os.path.join(args.log_dir_path, log_path)
handler = logging.FileHandler(log_path)
logger.addHandler(handler) logger.addHandler(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)
@ -286,6 +292,8 @@ def run(args):
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 args.make_test_case:
handler.close()
logger.removeHandler(handler)
result['retval'] += make_test_case(args, npy_savename, sync_was_successful) result['retval'] += make_test_case(args, npy_savename, sync_was_successful)
return result return result
@ -354,6 +362,8 @@ def add_cli_only_args(parser):
'--ffmpeg-path', '--ffmpegpath', default=None, '--ffmpeg-path', '--ffmpegpath', default=None,
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 '
'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)

Loading…
Cancel
Save