Skip to content

Commit

Permalink
Make sure fix_webvtt_separator is passed bytes or str
Browse files Browse the repository at this point in the history
  • Loading branch information
rlaphoenix committed Dec 2, 2023
1 parent ada1fee commit b8cf7a2
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions devine/core/tracks/subtitle.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,10 +191,13 @@ def fix_webvtt_separator(data: Union[str, bytes]):
"""
if isinstance(data, bytes):
data = data.decode("utf8")
text = data.replace("WEBVTT", "\n\nWEBVTT"). \
replace("\r", ""). \
replace("\n\n\n", "\n \n\n"). \
replace("\n\n<", "\n<")
elif not isinstance(data, str):
raise ValueError(f"Expecting data to be a str, not {data!r}")

text = data.replace("WEBVTT", "\n\nWEBVTT").\
replace("\r", "").\
replace("\n\n\n", "\n \n\n").\
replace("\n\n<", "\n<")

return text

Expand Down

0 comments on commit b8cf7a2

Please sign in to comment.