mirror of
https://github.com/unshackle-dl/unshackle.git
synced 2026-11-12 20:15:10 +00:00
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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user