diff options
author | Louis Vézina <[email protected]> | 2020-09-06 08:28:38 -0400 |
---|---|---|
committer | Louis Vézina <[email protected]> | 2020-09-06 08:28:38 -0400 |
commit | 1f8194c25a6b5bd975c9cdfc46269c88b3a5b456 (patch) | |
tree | 31fd3004e4d27aaf282cd766b3847334734f4fe2 /libs/ffsubsync | |
parent | 2fdc0dbdade889c128a4540e973bced13acb6dcb (diff) | |
download | bazarr-1f8194c25a6b5bd975c9cdfc46269c88b3a5b456.tar.gz bazarr-1f8194c25a6b5bd975c9cdfc46269c88b3a5b456.zip |
Update ffsubsync
Diffstat (limited to 'libs/ffsubsync')
-rw-r--r-- | libs/ffsubsync/_version.py | 4 | ||||
-rw-r--r-- | libs/ffsubsync/ffsubsync.py | 22 | ||||
-rw-r--r-- | libs/ffsubsync/speech_transformers.py | 2 |
3 files changed, 17 insertions, 11 deletions
diff --git a/libs/ffsubsync/_version.py b/libs/ffsubsync/_version.py index 83abafbaf..fac1f364c 100644 --- a/libs/ffsubsync/_version.py +++ b/libs/ffsubsync/_version.py @@ -24,8 +24,8 @@ def get_keywords(): # each be defined on a line of their own. _version.py will just call # get_keywords(). git_refnames = " (HEAD -> master)" - git_full = "997749de8aac74ec19137a2e641b97ef1bba81ea" - git_date = "2020-08-04 20:06:18 -0700" + git_full = "ce46d91fa2d325a13c2830f8030a316ed49b6cc9" + git_date = "2020-09-05 11:15:34 -0700" keywords = {"refnames": git_refnames, "full": git_full, "date": git_date} return keywords diff --git a/libs/ffsubsync/ffsubsync.py b/libs/ffsubsync/ffsubsync.py index b05249297..e3b08430b 100644 --- a/libs/ffsubsync/ffsubsync.py +++ b/libs/ffsubsync/ffsubsync.py @@ -49,7 +49,7 @@ def make_test_case(args, npy_savename, sync_was_successful): 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(log_path, tar_dir) shutil.copy(args.srtin, tar_dir) if sync_was_successful: shutil.move(args.srtout, tar_dir) @@ -267,12 +267,14 @@ def run(args): 'when reference composed of subtitles') result['retval'] = 1 return result + log_handler = None + log_path = None if args.make_test_case: 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) + log_handler = logging.FileHandler(log_path) + logger.addHandler(log_handler) if args.extract_subs_from_stream is not None: result['retval'] = extract_subtitles_from_reference(args) return result @@ -291,10 +293,14 @@ def run(args): return result 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) + if log_handler is not None and log_path is not None: + assert args.make_test_case + log_handler.close() + logger.removeHandler(log_handler) + try: + result['retval'] += make_test_case(args, npy_savename, sync_was_successful) + finally: + os.remove(log_path) 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.' ) 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('--gui-mode', action='store_true', help=argparse.SUPPRESS) diff --git a/libs/ffsubsync/speech_transformers.py b/libs/ffsubsync/speech_transformers.py index 02a7f332b..8290f82f9 100644 --- a/libs/ffsubsync/speech_transformers.py +++ b/libs/ffsubsync/speech_transformers.py @@ -233,7 +233,7 @@ class VideoSpeechTransformer(TransformerMixin): if not in_bytes: break newstuff = len(in_bytes) / float(bytes_per_frame) / self.frame_rate - if simple_progress + newstuff > total_duration: + if total_duration is not None and simple_progress + newstuff > total_duration: newstuff = total_duration - simple_progress simple_progress += newstuff pbar.update(newstuff) |