summaryrefslogtreecommitdiff
path: root/includes/process.js
diff options
context:
space:
mode:
Diffstat (limited to 'includes/process.js')
-rw-r--r--includes/process.js24
1 files changed, 19 insertions, 5 deletions
diff --git a/includes/process.js b/includes/process.js
index 88a477b..0c34f94 100644
--- a/includes/process.js
+++ b/includes/process.js
@@ -16,9 +16,11 @@ const substitutes = [
if (!fs.existsSync("../assets/content/_")) fs.mkdirSync("../assets/content/_");
if (!fs.existsSync("../assets/content/songs.json")) fs.writeFileSync("../assets/content/songs.json", "{}");
if (!fs.existsSync("../assets/content/albums.json")) fs.writeFileSync("../assets/content/albums.json", "{}");
+if (!fs.existsSync("../assets/content/archive.json")) fs.writeFileSync("../assets/content/archive.json", "{}");
const songs = require('../assets/content/songs.json');
const albums = require('../assets/content/albums.json');
+const archive = require('../assets/content/archive.json');
function scandir(dir) {
let count = 0;
@@ -111,9 +113,9 @@ function timeToString(time) {
function updateETA() {
if (timePerOp.length > 5) {
- process.stdout.write("(" + timeToString((list.length - index) * (timePerOp.reduce((a, b) => a + b) / timePerOp.length)) + ")");
+ process.stdout.write("(" + timeToString((list.length - index) * (timePerOp.reduce((a, b) => a + b) / timePerOp.length)) + " remaining | " + index + "/" + list.length + " processed | " + ((index / list.length) * 100).toFixed(1) + "% complete)");
} else {
- process.stdout.write("");
+ process.stdout.write("(" + index + "/" + list.length + " processed | " + ((index / list.length) * 100).toFixed(1) + "% complete)");
}
}
@@ -163,12 +165,22 @@ function timeToString(time) {
process.stdout.clearLine(null); process.stdout.cursorTo(0);
console.log(" Encoding FLAC version...");
updateETA();
- cp.execFileSync("ffmpeg", ["-i", file, "-map", "0", "-map", "-0:v?", "-c:a", "copy", "/opt/mist/flac/" + id + ".flac"], { stdio: "ignore" });
+ archive[id] = file;
+ fs.writeFileSync("../assets/content/archive.json", JSON.stringify(archive));
+ fs.copyFileSync(file, "/opt/mist/flac/" + id + ".flac");
process.stdout.clearLine(null); process.stdout.cursorTo(0);
console.log(" Extracting album art...");
updateETA();
- cp.execFileSync("ffmpeg", ["-i", file, "-an", "/opt/mist/jpeg/" + id + ".jpg"], { stdio: "ignore" });
+
+ try {
+ cp.execFileSync("ffmpeg", ["-i", file, "-an", "/opt/mist/jpeg/" + id + ".jpg"], { stdio: "ignore" });
+ } catch (e) {
+ process.stdout.clearLine(null); process.stdout.cursorTo(0);
+ console.error(e);
+ updateETA();
+ fs.copyFileSync("../assets/default.jpg", "/opt/mist/jpeg/" + id + ".jpg");
+ }
} else {
process.stdout.clearLine(null); process.stdout.cursorTo(0);
console.log(" Encoding AAC version...");
@@ -178,7 +190,9 @@ function timeToString(time) {
process.stdout.clearLine(null); process.stdout.cursorTo(0);
console.log(" Encoding FLAC version...");
updateETA();
- cp.execFileSync("ffmpeg", ["-i", file, "-map", "0", "-map", "-0:v?", "-c:a", "copy", "../assets/content/" + id + ".flac"], { stdio: "ignore" });
+ archive[id] = file;
+ fs.writeFileSync("../assets/content/archive.json", JSON.stringify(archive));
+ fs.copyFileSync(file, "../assets/content/" + id + ".flac");
process.stdout.clearLine(null); process.stdout.cursorTo(0);
console.log(" Extracting album art...");