Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions av/subtitles/subtitle.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,8 +294,9 @@ def dialogue(self):
Extract the plain text from the ASS dialogue line.

Override tags and comments (``{...}`` blocks) are removed, ``\\N``
becomes a newline, and ``\\n`` and ``\\h`` become a space. A ``{``
with no closing ``}`` is kept as literal text.
becomes a newline, ``\\n`` and ``\\h`` become a space, and ``\\{``
and ``\\}`` become literal braces. A ``{`` with no closing ``}`` is
kept as literal text.
"""
ass_text: bytes = self.ass
text_len: cython.Py_ssize_t = len(ass_text)
Expand Down Expand Up @@ -325,6 +326,10 @@ def dialogue(self):
result.append(b" "[0])
i += 2
continue
if char == b"\\"[0] and (next_char == b"{"[0] or next_char == b"}"[0]):
result.append(next_char)
i += 2
continue
if char == b"{"[0] and i < last_close:
in_block = True
else:
Expand Down
2 changes: 1 addition & 1 deletion scripts/ffmpeg-8.1.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"url": "https://github.com/PyAV-Org/pyav-ffmpeg/releases/download/8.1.2-1/ffmpeg-{platform}.tar.gz"
"url": "https://github.com/PyAV-Org/pyav-ffmpeg/releases/download/8.1.3-1/ffmpeg-{platform}.tar.gz"
}
2 changes: 1 addition & 1 deletion scripts/ffmpeg-latest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"url": "https://github.com/PyAV-Org/pyav-ffmpeg/releases/download/9.0.2-1/ffmpeg-{platform}.tar.gz"
"url": "https://github.com/PyAV-Org/pyav-ffmpeg/releases/download/9.0.2-4/ffmpeg-{platform}.tar.gz"
}
3 changes: 3 additions & 0 deletions tests/test_subtitles.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,9 @@ def dialogue(text: bytes) -> bytes:
assert dialogue(prefix + b"a\\Nb") == b"a\nb"
assert dialogue(prefix + b"a\\nb") == b"a b"
assert dialogue(prefix + b"a\\hb") == b"a b"
# Escaped braces are literal and don't open a block.
assert dialogue(prefix + b"a\\{b\\}c") == b"a{b}c"
assert dialogue(prefix + b"\\{x{\\i1}y") == b"{xy"
# A stray '{' with no closing '}' is literal text.
assert dialogue(prefix + b"cost is {5") == b"cost is {5"
# Commas in the Text field are kept.
Expand Down
Loading