Skip to content

Commit

Permalink
Add support for the WebVTT format.
Browse files Browse the repository at this point in the history
The underlying pysubs2 packages supports WebVTT so all this does is allows "vtt" subs to be passed through both for reading and writing.
  • Loading branch information
AaronAsAChimp committed Oct 28, 2024
1 parent bafd232 commit a0b77e7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions ffsubsync/generic_subtitles.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def write_file(self, fname: str) -> None:
else:
out_format = os.path.splitext(fname)[-1][1:]
subs = list(self.gen_raw_resolved_subs())
if self._sub_format in ("ssa", "ass"):
if self._sub_format in ("ssa", "ass", "vtt"):
ssaf = pysubs2.SSAFile()
ssaf.events = subs
if self._styles is not None:
Expand All @@ -149,7 +149,7 @@ def write_file(self, fname: str) -> None:
if self._fonts_opaque is not None:
ssaf.fonts_opaque = self._fonts_opaque
to_write = ssaf.to_string(out_format)
elif self._sub_format == "srt" and out_format in ("ssa", "ass"):
elif self._sub_format == "srt" and out_format in ("ssa", "ass", "vtt"):
to_write = pysubs2.SSAFile.from_string(srt.compose(subs)).to_string(
out_format
)
Expand Down
2 changes: 1 addition & 1 deletion ffsubsync/subtitle_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def fit(self, fname: str, *_) -> "GenericSubtitleParser":
parsed_subs = srt.parse(
decoded_subs, ignore_errors=not self._strict
)
elif self.sub_format in ("ass", "ssa", "sub"):
elif self.sub_format in ("ass", "ssa", "sub", "vtt"):
parsed_subs = pysubs2.SSAFile.from_string(decoded_subs)
else:
raise NotImplementedError(
Expand Down

0 comments on commit a0b77e7

Please sign in to comment.