Last active
March 2, 2016 23:55
Revisions
-
kizdolf revised this gist
Mar 2, 2016 . No changes.There are no files selected for viewing
-
kizdolf revised this gist
Mar 2, 2016 . 1 changed file with 16 additions and 9 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -4,18 +4,25 @@ var fs = require('fs'), readline = require('readline'); var ass_to_vtt = (file_in, file_out, cb)=>{ var order = [], gotOrder = false; fs.writeFileSync(file_out, 'WEBVTT\n\n'); readline.createInterface({ input: fs.createReadStream(file_in) }).on('line', (line)=>{ if(/Format: /.test(line)){ order = line.split('Format: ')[1].split(', '); if(order.indexOf('Text') !== -1) gotOrder = true; }else if(gotOrder && /Dialogue: /.test(line)){ var explode = line.split('Dialogue: ')[1].split(','); if(explode.length == order.length){ var start = '0' + explode[order.indexOf('Start')], end = '0' + explode[order.indexOf('End')], txt = explode[order.indexOf('Text')], vtt = (start + ' --> ' + end + '\n' + txt + '\n\n'); fs.appendFileSync(file_out, vtt); } } }).on('close', ()=>{ cb(true); @@ -24,4 +31,4 @@ var ass_to_vtt = (file_in, file_out, cb)=>{ ass_to_vtt('English.ass', 'English.vtt', ()=>{ console.log('done'); }); -
kizdolf revised this gist
Mar 2, 2016 . 1 changed file with 15 additions and 7 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,19 +1,27 @@ 'use strict'; var fs = require('fs'), readline = require('readline'); var ass_to_vtt = (file_in, file_out, cb)=>{ var reg = /Dialogue: [0-9],([0-9]:([0-9]{2}):[0-9]{2}.[0-9]{2}),([0-9]:([0-9]{2}):[0-9]{2}.[0-9]{2}).*,,(.*)/g; fs.writeFileSync(file_out, 'WEBVTT\n\n'); readline.createInterface({ input: fs.createReadStream(file_in) }).on('line', (line)=>{ var explode = line.split(reg); if(explode.length == 7){ var start = '0' + explode[1], end = '0' + explode[3], txt = explode[5], vtt = (start + ' --> ' + end + '\n' + txt + '\n\n'); fs.appendFileSync(file_out, vtt); } }).on('close', ()=>{ cb(true); }); }; ass_to_vtt('English.ass', 'English.vtt', ()=>{ console.log('done'); }); -
kizdolf revised this gist
Mar 2, 2016 . 1 changed file with 1 addition and 8 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,4 @@ 'use strict'; var fs = require('fs'), readline = require('readline'); @@ -8,13 +7,7 @@ var ass_to_vtt = (file_in, file_out, cb)=>{ input: fs.createReadStream(file_in) }); lineReader.on('line', (line)=>{ fs.appendFileSync(file_out, line.replace(/~(\\\\N)?\{[^}]*\}~/, '') + '\n'); }); lineReader.on('close', ()=>{ cb(true); -
kizdolf renamed this gist
Mar 2, 2016 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
kizdolf revised this gist
Mar 2, 2016 . No changes.There are no files selected for viewing
-
kizdolf created this gist
Mar 2, 2016 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,26 @@ 'use strict'; var fs = require('fs'), readline = require('readline'); var ass_to_vtt = (file_in, file_out, cb)=>{ var lineReader = readline.createInterface({ input: fs.createReadStream(file_in) }); lineReader.on('line', (line)=>{ var line_vtt = ''; var reg = /~(\\\\N)?\{[^}]*\}~/; var exp = line.split(reg); exp.forEach((part)=>{ line_vtt += part; }); fs.appendFileSync(file_out, line_vtt + "\n"); }); lineReader.on('close', ()=>{ cb(true); }); }; ass_to_vtt('English.ass', 'English.vtt', ()=>{ console.log('done'); });