summaryrefslogtreecommitdiffhomepage
path: root/libs/ffsubsync
diff options
context:
space:
mode:
authorLouis Vézina <[email protected]>2020-08-19 15:23:43 -0400
committerLouis Vézina <[email protected]>2020-08-19 15:23:43 -0400
commit6ad4843cdfbe213141f14ff760e4117ed6688d5b (patch)
tree7f6f93210eb54834563da889dc08f3b2ba001811 /libs/ffsubsync
parent5dbde75893e984b667c8e35f224bff48fd7825e9 (diff)
downloadbazarr-6ad4843cdfbe213141f14ff760e4117ed6688d5b.tar.gz
bazarr-6ad4843cdfbe213141f14ff760e4117ed6688d5b.zip
Multiple fixes to ffsubsync.
Diffstat (limited to 'libs/ffsubsync')
-rw-r--r--libs/ffsubsync/ffsubsync.py24
1 files changed, 17 insertions, 7 deletions
diff --git a/libs/ffsubsync/ffsubsync.py b/libs/ffsubsync/ffsubsync.py
index 18d772c12..31815762f 100644
--- a/libs/ffsubsync/ffsubsync.py
+++ b/libs/ffsubsync/ffsubsync.py
@@ -41,12 +41,15 @@ def make_test_case(args, npy_savename, sync_was_successful):
raise ValueError('need non-null npy_savename')
tar_dir = '{}.{}'.format(
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))
os.mkdir(tar_dir)
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)
if sync_was_successful:
shutil.move(args.srtout, tar_dir)
@@ -62,10 +65,10 @@ def make_test_case(args, npy_savename, sync_was_successful):
if archive_format in supported_formats:
shutil.make_archive(tar_dir, 'gztar', os.curdir, tar_dir)
break
- else:
- logger.error('failed to create test archive; no formats supported '
- '(this should not happen)')
- return 1
+ else:
+ logger.error('failed to create test archive; no formats supported '
+ '(this should not happen)')
+ return 1
logger.info('...done')
finally:
shutil.rmtree(tar_dir)
@@ -265,7 +268,10 @@ def run(args):
result['retval'] = 1
return result
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)
if args.extract_subs_from_stream is not None:
result['retval'] = extract_subtitles_from_reference(args)
@@ -286,6 +292,8 @@ def run(args):
srt_pipes = make_srt_pipes(args)
sync_was_successful = try_sync(args, reference_pipe, srt_pipes, result)
if args.make_test_case:
+ handler.close()
+ logger.removeHandler(handler)
result['retval'] += make_test_case(args, npy_savename, sync_was_successful)
return result
@@ -354,6 +362,8 @@ def add_cli_only_args(parser):
'--ffmpeg-path', '--ffmpegpath', default=None,
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('--gui-mode', action='store_true', help=argparse.SUPPRESS)