Created
February 27, 2018 18:46
-
-
Save vladzadvorny/743e2f49f0a3d7f89b4071593145acf7 to your computer and use it in GitHub Desktop.
This file contains 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
const { read } = require("readdir"); | |
const fs = require("fs"); | |
const parser = require("subtitles-parser"); | |
const stream = fs.createWriteStream("./file.txt"); | |
read("/Users/vlad/Desktop/Node", ["**/*.srt"], (err, paths) => | |
paths.forEach(item => { | |
const srt = fs.readFileSync("/Users/vlad/Desktop/Node/" + item, "utf8"); | |
const data = parser.fromSrt(srt); | |
const arr = []; | |
arr.push(`\n\n${item}\n\n`); | |
data.forEach(item2 => { | |
arr.push(item2.text.replace(/\n/g, " ")); | |
}); | |
stream.write(arr.join(" ")); | |
}) | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment