Update ffsubsync

pull/1102/head
Louis Vézina 4 years ago
parent 2fdc0dbdad
commit 1f8194c25a

@ -24,8 +24,8 @@ def get_keywords():
# each be defined on a line of their own. _version.py will just call # each be defined on a line of their own. _version.py will just call
# get_keywords(). # get_keywords().
git_refnames = " (HEAD -> master)" git_refnames = " (HEAD -> master)"
git_full = "997749de8aac74ec19137a2e641b97ef1bba81ea" git_full = "ce46d91fa2d325a13c2830f8030a316ed49b6cc9"
git_date = "2020-08-04 20:06:18 -0700" git_date = "2020-09-05 11:15:34 -0700"
keywords = {"refnames": git_refnames, "full": git_full, "date": git_date} keywords = {"refnames": git_refnames, "full": git_full, "date": git_date}
return keywords return keywords

@ -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)

@ -233,7 +233,7 @@ class VideoSpeechTransformer(TransformerMixin):
if not in_bytes: if not in_bytes:
break break
newstuff = len(in_bytes) / float(bytes_per_frame) / self.frame_rate 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 newstuff = total_duration - simple_progress
simple_progress += newstuff simple_progress += newstuff
pbar.update(newstuff) pbar.update(newstuff)

Loading…
Cancel
Save