diff --git a/buzz/plugins/skip_already_transcribed/plugin.py b/buzz/plugins/skip_already_transcribed/plugin.py index ff9387553..329ab5a26 100644 --- a/buzz/plugins/skip_already_transcribed/plugin.py +++ b/buzz/plugins/skip_already_transcribed/plugin.py @@ -1,3 +1,4 @@ +import glob import logging import os import re @@ -89,7 +90,7 @@ def _find_result_file_segments(self, file_path: str, task, context: PluginContex if not search_dir.is_dir(): continue for fmt in OutputFormat: - for candidate in search_dir.glob(f"{stem}*.{fmt.value}"): + for candidate in search_dir.glob(f"{glob.escape(stem)}*.{fmt.value}"): segments = self._parse_result_file(candidate, fmt, context) if segments is not None: return segments diff --git a/tests/plugins/plugin_system_test.py b/tests/plugins/plugin_system_test.py index 87db31306..20251304a 100644 --- a/tests/plugins/plugin_system_test.py +++ b/tests/plugins/plugin_system_test.py @@ -788,6 +788,22 @@ def test_sat_skips_on_vtt_file(tmp_path): assert result[1].start == 3000 +def test_sat_skips_on_srt_file_with_brackets_in_name(tmp_path): + plugin = _sat_plugin() + audio = tmp_path / "Interview [Part 1].mp3" + audio.write_bytes(b"") + srt = tmp_path / "Interview [Part 1] (transcribed on 01-Jan-2024 12-00-00).srt" + srt.write_text( + "1\n00:00:01,000 --> 00:00:03,500\nHello there.\n\n", + encoding="utf-8", + ) + + ctx = _sat_context(config={"check_result_files": True, "check_database": False}) + result = plugin.check_skip(_SatTask(file_path=str(audio)), ctx) + assert result is not None + assert result[0].text == "Hello there." + + def test_sat_returns_none_when_result_files_disabled(tmp_path): plugin = _sat_plugin() audio = tmp_path / "audio.mp3"