Merge branch 'fix/review-2077' into fix/community-integration

This commit is contained in:
Palash Debnath
2026-09-17 14:01:28 +05:30
2 changed files with 4 additions and 3 deletions
+1 -1
View File
@@ -86,7 +86,7 @@ def parse_srt(content: str) -> SrtParseResult:
# example timestamp inside a NOTE/STYLE/REGION cannot become speech.
blocks = []
for block in re.split(r"\n[^\S\n]*\n", text):
lines = block.strip("\n").split("\n")
lines = block.strip().split("\n")
first = lines[0].strip()
# WebVTT's block parser gives a timing line in position two
# precedence over the identifier (including STYLE/REGION/NOTE).
+3 -2
View File
@@ -374,8 +374,9 @@ def test_numeric_only_cue_after_invalid_cue_is_not_discarded():
@pytest.mark.parametrize('header', ['NOTE', 'NOTE translator notes', 'NOTE\ttranslator notes', 'STYLE', 'REGION'])
def test_webvtt_metadata_timestamps_never_become_dialogue(header):
text = f'WEBVTT\n\n{header}\nMetadata content\n00:00.000 --> 00:02.000\nMetadata only\n\ncue\n00:03.000 --> 00:04.000\nReal dialogue\n'
@pytest.mark.parametrize('separator', ['\n\n', '\n\n \n', '\n \n\n'])
def test_webvtt_metadata_timestamps_never_become_dialogue(header, separator):
text = f'WEBVTT{separator}{header}\nMetadata content\n00:00.000 --> 00:02.000\nMetadata only\n\ncue\n00:03.000 --> 00:04.000\nReal dialogue\n'
result = parse_srt(text)
assert [cue['text'] for cue in result.segments] == ['Real dialogue']
assert result.segments[0]['start'] == 3