From ead05d08ac9d9dd1027bb1a41b43b3d8b9123838 Mon Sep 17 00:00:00 2001 From: Andy Date: Wed, 6 Aug 2025 01:28:03 +0000 Subject: [PATCH] fix(subtitle): Handle ValueError in subtitle filtering for multiple colons in time references fixes issues with subtitles that contain multiple colons --- unshackle/core/tracks/subtitle.py | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/unshackle/core/tracks/subtitle.py b/unshackle/core/tracks/subtitle.py index 4609c64..d2a5cad 100644 --- a/unshackle/core/tracks/subtitle.py +++ b/unshackle/core/tracks/subtitle.py @@ -870,7 +870,18 @@ class Subtitle(Track): elif sdh_method == "filter-subs": # Force use of filter-subs sub = Subtitles(self.path) - sub.filter(rm_fonts=True, rm_ast=True, rm_music=True, rm_effects=True, rm_names=True, rm_author=True) + try: + sub.filter(rm_fonts=True, rm_ast=True, rm_music=True, rm_effects=True, rm_names=True, rm_author=True) + except ValueError as e: + if "too many values to unpack" in str(e): + # Retry without name removal if the error is due to multiple colons in time references + # This can happen with lines like "at 10:00 and 2:00" + sub = Subtitles(self.path) + sub.filter( + rm_fonts=True, rm_ast=True, rm_music=True, rm_effects=True, rm_names=False, rm_author=True + ) + else: + raise sub.save() return elif sdh_method == "auto": @@ -906,7 +917,18 @@ class Subtitle(Track): ) else: sub = Subtitles(self.path) - sub.filter(rm_fonts=True, rm_ast=True, rm_music=True, rm_effects=True, rm_names=True, rm_author=True) + try: + sub.filter(rm_fonts=True, rm_ast=True, rm_music=True, rm_effects=True, rm_names=True, rm_author=True) + except ValueError as e: + if "too many values to unpack" in str(e): + # Retry without name removal if the error is due to multiple colons in time references + # This can happen with lines like "at 10:00 and 2:00" + sub = Subtitles(self.path) + sub.filter( + rm_fonts=True, rm_ast=True, rm_music=True, rm_effects=True, rm_names=False, rm_author=True + ) + else: + raise sub.save() def reverse_rtl(self) -> None: