Skip to content

Commit

Permalink
Use helper function to check for SRT files
Browse files Browse the repository at this point in the history
The existing raw globbing approach used for checking the presence of SRT subtitle files has been replaced with a helper function `check_for_file_with_extension()` from file.py module. This change is important as it enhances code reusability and makes it concise.
  • Loading branch information
cbusillo committed Jun 20, 2024
1 parent 43bf219 commit 4dfe327
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion bd_to_avp/modules/sub.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

from bd_to_avp.modules.config import config
from bd_to_avp.modules.command import Spinner
from bd_to_avp.modules.file import check_for_file_with_extension


class SRTCreationError(Exception):
Expand Down Expand Up @@ -49,7 +50,7 @@ def extract_subtitle_to_srt(mkv_path: Path, output_path: Path) -> None:
if srt_file.stat().st_size == 0:
srt_file.unlink()

if not any(output_path.glob("*.srt")) and not config.continue_on_error:
if not check_for_file_with_extension(output_path, "srt") and not config.continue_on_error:
raise SRTCreationError("No SRT subtitle files created.")

if forced_track_language:
Expand Down

0 comments on commit 4dfe327

Please sign in to comment.