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.
This commit is contained in:
2026-08-14 14:32:28 +02:00
parent 04ca437054
commit a90b516f49
+7 -1
View File
@@ -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)