fix srt parser
This commit is contained in:
parent
19be508afe
commit
c5534df039
2 changed files with 5 additions and 9 deletions
|
|
@ -207,9 +207,13 @@ Ox.parseSRT <f> Parses an srt subtitle file
|
|||
[{'in': 3720, out: 3723.4, text: 'Hello World'}]
|
||||
@*/
|
||||
Ox.parseSRT = function(string, fps) {
|
||||
return string.replace(/\r\n/g, '\n').replace(/\n+$/, '').split('\n\n')
|
||||
return string.replace(/\r\n/g, '\n').trim().split('\n\n')
|
||||
.map(function(block) {
|
||||
var lines = block.split('\n'), points;
|
||||
if (lines.length < 3) {
|
||||
Ox.Log('Core', 'skip invalid srt block', lines);
|
||||
continue;
|
||||
}
|
||||
lines.shift();
|
||||
points = lines.shift().split(' --> ').map(function(point) {
|
||||
return point.replace(',', ':').split(':')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue