Skip to content

Commit

Permalink
Fix SubMicroDvd recognition
Browse files Browse the repository at this point in the history
  • Loading branch information
mantas-done committed Mar 6, 2024
1 parent 20b84a5 commit f7a0748
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Code/Converters/SubMicroDvdConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

class SubMicroDvdConverter implements ConverterContract
{
static protected $fps = 23.975; // SubtitleEdit by default uses this fps. Taken that value without much thinking. Change it to a better values if you will find.
static protected $fps = 23.976; // SubtitleEdit by default uses this fps. Taken that value without much thinking. Change it to a better values if you will find.

public function canParseFileContent($file_content)
{
$pattern = "/\{\d+\}\{\d+\}(.*)\./";
$pattern = "/\{\d+\}\{\d+\}(.*)/";
return preg_match($pattern, $file_content, $matches);
}

Expand Down
11 changes: 11 additions & 0 deletions tests/formats/SubMicroDvdTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,15 @@ public function testParsesStyles()
$expected = $this->defaultSubtitles()->getInternalFormat();
$this->assertInternalFormatsEqual($expected, $actual, 0.25);
}

public function testParsesLinesWithoutDotAtTheEnd()
{
$content = <<<TEXT
{0}{100}Subtitle line 1
{150}{300}Subtitle line 2
TEXT;
$actual = Subtitles::loadFromString($content)->getInternalFormat();
$expected = (new Subtitles())->add(0, 4.17, 'Subtitle line 1')->add(6.26, 12.51, 'Subtitle line 2')->getInternalFormat();
$this->assertInternalFormatsEqual($expected, $actual);
}
}

0 comments on commit f7a0748

Please sign in to comment.