Created
July 18, 2014 08:33
-
-
Save miracle2k/0a445bd62cec11409d9c to your computer and use it in GitHub Desktop.
Old code, trying to parse ASS files.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://github.com/Arnavion/libjass | |
// https://github.com/spiegeleixxl/html5-ass-subtitles/blob/master/assparser.js | |
Subtitles = {}; | |
Subtitles.ASS = function(content) { | |
var linesOfDialog = []; | |
function parse(content) { | |
var lines = content.split('\n'); | |
var inEventsSection = false; | |
for (var i=0; i<lines.length; i++) { | |
if (lines[i].startsWith('[Events]')) | |
inEventsSection = true; | |
else if (!inEventsSection) | |
continue; | |
else { | |
if (lines[i].startsWith('Dialogue:')) { | |
var parts = lines[i].split(','); | |
var st = lineparts[1].trim().split(':'); | |
var et = lineparts[2].trim().split(':'); | |
var startTime = st[0]*60*60 + st[1]*60 + parseFloat(st[2]); | |
var endTime = et[0]*60*60 + et[1]*60 + parseFloat(et[2]); | |
linesOfDialog.push({ | |
pre: linesPre + partsPre, | |
post: partsPost, | |
startTime: startTime, | |
endTime: endTime | |
}); | |
} | |
} | |
} | |
} | |
this.serialize = function() { | |
linesOfDialog.forEach(function(line) { | |
out(line.pre); | |
out(line.startTime); | |
out(','); | |
out(line.endTime); | |
out(line.post); | |
}); | |
out(postamble) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment