diff options
author | Louis Vézina <[email protected]> | 2020-08-05 07:04:01 -0400 |
---|---|---|
committer | Louis Vézina <[email protected]> | 2020-08-05 07:04:01 -0400 |
commit | 49dd078fa1266e9d90cafb1b3d777f902eeaea23 (patch) | |
tree | 03321ff609b527522961011d4e61ff0d8ba4887e /libs/ffsubsync | |
parent | ea097d6ec4576629370d1333967440d49d37379e (diff) | |
download | bazarr-49dd078fa1266e9d90cafb1b3d777f902eeaea23.tar.gz bazarr-49dd078fa1266e9d90cafb1b3d777f902eeaea23.zip |
Updated ffsubsync to better manage access denied exception on files.
Diffstat (limited to 'libs/ffsubsync')
-rw-r--r-- | libs/ffsubsync/_version.py | 4 | ||||
-rw-r--r-- | libs/ffsubsync/ffmpeg_utils.py | 1 | ||||
-rw-r--r-- | libs/ffsubsync/ffsubsync.py | 21 |
3 files changed, 23 insertions, 3 deletions
diff --git a/libs/ffsubsync/_version.py b/libs/ffsubsync/_version.py index 6dffdc4de..83abafbaf 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 = "558bc6dc1d5342d4a5910166cf12ebb5890e86b7" - git_date = "2020-07-11 17:02:56 -0700" + git_full = "997749de8aac74ec19137a2e641b97ef1bba81ea" + git_date = "2020-08-04 20:06:18 -0700" keywords = {"refnames": git_refnames, "full": git_full, "date": git_date} return keywords diff --git a/libs/ffsubsync/ffmpeg_utils.py b/libs/ffsubsync/ffmpeg_utils.py index c1c8a6ab1..2bb0876db 100644 --- a/libs/ffsubsync/ffmpeg_utils.py +++ b/libs/ffsubsync/ffmpeg_utils.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- import logging import os import platform diff --git a/libs/ffsubsync/ffsubsync.py b/libs/ffsubsync/ffsubsync.py index 64c6e929e..18d772c12 100644 --- a/libs/ffsubsync/ffsubsync.py +++ b/libs/ffsubsync/ffsubsync.py @@ -206,7 +206,7 @@ def validate_args(args): raise ValueError('need to specify input and output srt files for test cases') if args.overwrite_input: if args.extract_subs_from_stream is not None: - raise ValueError('input overwriting not allowed for extracting subtitles from referece') + raise ValueError('input overwriting not allowed for extracting subtitles from reference') if args.srtin is None: raise ValueError( 'need to specify input srt if --overwrite-input is specified since we cannot overwrite stdin' @@ -222,6 +222,19 @@ def validate_args(args): raise ValueError('stream specified for reference subtitle extraction; -i flag for sync input not allowed') +def validate_file_permissions(args): + if not os.access(args.reference, os.R_OK): + raise ValueError('unable to read reference %s (try checking permissions)' % args.reference) + if not os.access(args.srtin, os.R_OK): + raise ValueError('unable to read input subtitles %s (try checking permissions)' % args.srtin) + if os.path.exists(args.srtout) and not os.access(args.srtout, os.W_OK): + raise ValueError('unable to write output subtitles %s (try checking permissions)' % args.srtout) + if args.make_test_case or args.serialize_speech: + npy_savename = os.path.splitext(args.reference)[0] + '.npz' + if os.path.exists(npy_savename) and not os.access(npy_savename, os.W_OK): + raise ValueError('unable to write test case file archive %s (try checking permissions)' % npy_savename) + + def run(args): result = { 'retval': 0, @@ -239,6 +252,12 @@ def run(args): args.srtout = args.srtin if args.gui_mode and args.srtout is None: args.srtout = '{}.synced.srt'.format(os.path.splitext(args.srtin)[0]) + try: + validate_file_permissions(args) + except ValueError as e: + logger.error(e) + result['retval'] = 1 + return result ref_format = _ref_format(args.reference) if args.merge_with_reference and ref_format not in SUBTITLE_EXTENSIONS: logger.error('merging synced output with reference only valid ' |