Module subtitles

Source
Expand description

Subtitle file formats: SubRip (.srt) and WebVTT (.vtt) โ€” parse (auto-detected) and write. Basic formatting tags (, , {\an8}, VTT cue settings) are stripped on import; text is kept as plain lines. Times are seconds.

Functionsยง

fmt_time ๐Ÿ”’
parse
Parse SRT or WebVTT (auto-detected by the โ€œWEBVTTโ€ header / timestamp style). Malformed blocks are skipped. Returns (start, end, text) triples in file order.
parse_block ๐Ÿ”’
One blank-line separated block: [optional index / cue-id lines,] timestamp line, text lines. The timestamp line is the first containing โ€œโ€“>โ€ (this also skips WEBVTT/NOTE/STYLE blocks).
parse_time ๐Ÿ”’
โ€œHH:MM:SS,mmmโ€ / โ€œHH:MM:SS.mmmโ€ / โ€œMM:SS.mmmโ€ โ†’ seconds.
strip_tags ๐Ÿ”’
Append s to out with <...> tags and {\...} override codes removed.
to_srt
to_vtt