-
Notifications
You must be signed in to change notification settings - Fork 15
/
index.js
39 lines (33 loc) · 990 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
'use strict'
const fs = require('fs')
const async = require('async');
const SrtConvert = require('./lib/srtConvert');
const srtConvert = new SrtConvert();
let sourcePath;
let destinationPath = 'output.srt';
if (process.argv[2] && fs.existsSync(process.argv[2]))
{
sourcePath = process.argv[2];
if (process.argv[3])
{
destinationPath = process.argv[3];
}
} else {
const express = require('express');
const app = express();
const prompt = require('prompt-sync')();
app.use(express.static('output'))
var path = prompt('Please provide the location of the Transcribe output: ');
}
fs.readFile(sourcePath, 'utf8', (err, file) => {
if (err) {
console.log(err);
return err
}
const convertedOutput = srtConvert.convertFile(file);
fs.writeFile(destinationPath, convertedOutput, (err) => {
if (err) throw err;
console.log(`SRT file written to '${destinationPath}'.`);
process.exit();
});
})