From 680f5059b52b0c8fa00367ef19fd02a7c102658f Mon Sep 17 00:00:00 2001 From: imSp4rky Date: Thu, 11 Jun 2026 19:09:06 -0600 Subject: [PATCH] fix(subtitle): drive SubtitleEdit 4.x with legacy /convert syntax Registry refactor (2923292) emitted seconv-only --flags; 4.x opened the GUI per subtitle. Pick syntax per binary; prefer seconv for 5.x. --- unshackle/core/binaries.py | 3 ++- unshackle/core/tracks/subtitle_convert.py | 30 +++++++++++++++++------ 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/unshackle/core/binaries.py b/unshackle/core/binaries.py index 65f92d0..d224588 100644 --- a/unshackle/core/binaries.py +++ b/unshackle/core/binaries.py @@ -37,7 +37,8 @@ def find(*names: str) -> Optional[Path]: FFMPEG = find("ffmpeg") FFProbe = find("ffprobe") FFPlay = find("ffplay") -SubtitleEdit = find("SubtitleEdit", "seconv") # seconv = cross-platform subtitleedit-cli (.NET 8) +# seconv = SubtitleEdit 5+ CLI (the 5.0 GUI has no batch mode); SubtitleEdit = 4.x +SubtitleEdit = find("seconv", "SubtitleEdit") ShakaPackager = find( "shaka-packager", "packager", diff --git a/unshackle/core/tracks/subtitle_convert.py b/unshackle/core/tracks/subtitle_convert.py index 986ef18..478f91f 100644 --- a/unshackle/core/tracks/subtitle_convert.py +++ b/unshackle/core/tracks/subtitle_convert.py @@ -65,6 +65,12 @@ PYSUBS2_FORMATS: dict[Codec, str] = { } +def is_seconv(binary: object) -> bool: + """True for the SubtitleEdit 5+ CLI (seconv); 4.x binaries need legacy /convert syntax.""" + name = str(binary).replace("\\", "/").rsplit("/", 1)[-1] + return name.lower().rsplit(".", 1)[0] == "seconv" + + def subtitleedit_args( binary: object, src: Path, @@ -76,15 +82,25 @@ def subtitleedit_args( reverse_rtl: bool = False, ) -> list[str]: """ - Build a SubtitleEdit batch-convert command. + Build a SubtitleEdit batch-convert command in 5.x (seconv ``--flags``) or 4.x + (``/convert /flags``) syntax, per ``is_seconv``. - Targets the SubtitleEdit 5+ CLI (``SeConv`` / ``seconv`` on every platform), which takes - ``--flags`` with a positional `` `` (no legacy ``/convert`` verb). The - SE5 converter names the output ``.``; pass ``output_folder`` to - place it next to a chosen path (a bare ``--output-filename`` resolves against the *cwd*, - not the input dir, so we always steer with ``--output-folder``). ``--overwrite`` is always - set so re-runs and in-place transforms (SDH/RTL) don't fail on an existing file. + Both name the output ``.``; ``output_folder`` steers placement + (a bare ``--output-filename`` resolves against the cwd, not the input dir). Overwrite is + always set so re-runs and in-place transforms (SDH/RTL) don't fail on an existing file. """ + if not is_seconv(binary): + args = [str(binary), "/convert", str(src), fmt, "/encoding:utf8", "/overwrite"] + if output_folder is not None: + args.append(f"/outputfolder:{output_folder}") + if convert_colors: + args.append("/ConvertColorsToDialog") + if remove_hi: + args.append("/RemoveTextForHI") + if reverse_rtl: + args.append("/ReverseRtlStartEnd") + return args + args = [str(binary), str(src), fmt, "--encoding:utf-8", "--overwrite"] if output_folder is not None: args.append(f"--output-folder:{output_folder}")