Skip to content

Commit

Permalink
Fix scc multiple spaces between blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
mantas-done committed Aug 30, 2023
1 parent 4c27d43 commit b2a4744
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/Code/Converters/SccConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,8 @@ protected static function addSpaceAfter4Characters($string) {

private static function sccToLines($data)
{
$blocks = explode(' ', trim($data));
$single_space = preg_replace('/\s+/', ' ', $data);
$blocks = explode(' ', trim($single_space));
$blocks = array_map('strtolower', $blocks);
$text = '';
foreach ($blocks as $block) {
Expand Down
13 changes: 13 additions & 0 deletions tests/formats/SccTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -212,4 +212,17 @@ public function testInternalTimeToSccTimeWithText()
$actual = SccConverter::internalTimeToScc(3600, 30);
$this->assertEquals('00:59:59;15', $actual, 0.001);
}

public function testSpaceBetweenBlocks()
{
$scc = "Scenarist_SCC V1.0
00:00:00;21 94ae 94ae 9420 9420 9470 9470 6180 942f 942f
00:00:01;26 942c 942c";
$actual = Subtitles::loadFromString($scc)->getInternalFormat();
$expected = (new Subtitles())->add(1, 2, 'a')->getInternalFormat();

$this->assertInternalFormatsEqual($expected, $actual, 0.1);
}
}

0 comments on commit b2a4744

Please sign in to comment.