From ef8eac1c2dd380c45434fdf7b9b0fdb1df82e359 Mon Sep 17 00:00:00 2001 From: Raul Tapia Date: Fri, 24 Oct 2025 12:26:29 +0200 Subject: [PATCH] Automatically detect input SRT files when none specified --- ffsubsync/ffsubsync.py | 11 +++++++++++ 1 file changed, 11 insertions(+) mode change 100755 => 100644 ffsubsync/ffsubsync.py diff --git a/ffsubsync/ffsubsync.py b/ffsubsync/ffsubsync.py old mode 100755 new mode 100644 index b0114cc..91e505d --- a/ffsubsync/ffsubsync.py +++ b/ffsubsync/ffsubsync.py @@ -336,6 +336,17 @@ def validate_args(args: argparse.Namespace) -> None: raise ValueError("cannot specify multiple input srt files for test cases") if len(args.srtin) > 1 and args.gui_mode: raise ValueError("cannot specify multiple input srt files in GUI mode") + else: + logger.info("No input srt specified; automatically detecting input str") + reference_base = os.path.splitext(args.reference)[0] + matching_files = [file for file in os.listdir() if file.startswith(reference_base) and file.endswith('.srt')] + if not matching_files: + raise ValueError("No matching input srt files found for reference.") + else: + args.srtin = matching_files + args.overwrite_input = True + for file in matching_files: + logger.info("Detected input srt: %s", file) if ( args.make_test_case and not args.gui_mode ): # this validation not necessary for gui mode