From a90b516f4944f07e5818fc6254bbed66bf022fcb Mon Sep 17 00:00:00 2001 From: nessi Date: Fri, 14 Aug 2026 14:32:28 +0200 Subject: [PATCH] fix: replace glob() with iterdir() in external_subtitle_files() to handle square brackets in media filenames Replace glob pattern matching with iterdir() + startswith() filtering to avoid glob interpreting square brackets (e.g., [Bluray-1080p]) as pattern characters. Add OSError exception handling to return empty list when directory access fails. --- app.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app.py b/app.py index 8abe2e0..04ec523 100644 --- a/app.py +++ b/app.py @@ -184,7 +184,13 @@ EXTERNAL_SUBTITLE_EXTENSIONS = {".srt", ".ass", ".ssa", ".vtt", ".sub", ".idx", def external_subtitle_files(path): media = Path(path) - return sorted(candidate for candidate in media.parent.glob(f"{media.stem}.*") if candidate.suffix.lower() in EXTERNAL_SUBTITLE_EXTENSIONS) + prefix = f"{media.stem}." + # Nicht glob() verwenden: Mediennamen enthalten oft eckige Klammern + # wie [Bluray-1080p], die glob als Pattern-Zeichen interpretieren würde. + try: + return sorted(candidate for candidate in media.parent.iterdir() if candidate.is_file() and candidate.name.startswith(prefix) and candidate.suffix.lower() in EXTERNAL_SUBTITLE_EXTENSIONS) + except OSError: + return [] def external_subtitle_languages(path): media = Path(path)