fix(subtitle): keep cue-less webvtt instead of failing the download

A rendition with headers but no cues raised CaptionReadNoCaptions when preserve_formatting is false, aborting the whole download.
This commit is contained in:
imSp4rky
2026-08-12 11:42:15 -06:00
parent 16ae73e3a0
commit 274b2fc308
+3
View File
@@ -291,6 +291,9 @@ class Subtitle(Track):
Subtitle.filter_unwanted_cues(caption_set)
subtitle_text = pycaption.WebVTTWriter().write(caption_set)
self.path.write_text(subtitle_text, encoding="utf8")
except pycaption.exceptions.CaptionReadNoCaptions:
# some renditions carry headers but no cues; write them out rather than fail the download
self.path.write_text(text, encoding="utf8")
except pycaption.exceptions.CaptionReadSyntaxError:
# If first attempt fails, try more aggressive sanitization
text = Subtitle.sanitize_webvtt(text)