Skip to content

Commit

Permalink
Fix vtt parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
mantas-done committed Dec 4, 2023
1 parent 5960e28 commit 4bf51c9
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Code/Converters/VttConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function fileContentToInternalFormat($file_content, $original_file_conten
unset($internal_format[$i - 1]['lines'][$count - 1]);
}
}
} elseif (TxtConverter::hasText($line)) {
} elseif (trim($line) !== '') {
$text_line = $line;
// speaker
$speaker = null;
Expand Down
21 changes: 21 additions & 0 deletions tests/formats/VttTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -387,4 +387,25 @@ public function testTextIsNotRecognizedAsTimestamp()
->getInternalFormat();
$this->assertEquals($expected, $actual);
}

public function testClientFile()
{
$given = <<< TEXT
WEBVTT
1
00:00:00.000 --> 00:00:01.000
a
2
00:00:01.000 --> 00:00:02.000
b
TEXT;
$actual = (new Subtitles())->loadFromString($given)->getInternalFormat();
$expected = (new Subtitles())
->add(0, 1, 'a')
->add(1, 2, 'b')
->getInternalFormat();
$this->assertEquals($expected, $actual);
}
}

0 comments on commit 4bf51c9

Please sign in to comment.