diff options
author | RaindropsSys <raindrops@equestria.dev> | 2023-10-27 22:29:56 +0200 |
---|---|---|
committer | RaindropsSys <raindrops@equestria.dev> | 2023-10-27 22:29:56 +0200 |
commit | 4d4308c46d4f7801c657cc79d2243e1a81831334 (patch) | |
tree | a2e392e0af92b9a3ca3d1b5afb841640276e2294 /includes/process.js | |
parent | 9f9d66afebc59c6c265c4424f7b8fb36d8876541 (diff) | |
download | mist-4d4308c46d4f7801c657cc79d2243e1a81831334.tar.gz mist-4d4308c46d4f7801c657cc79d2243e1a81831334.tar.bz2 mist-4d4308c46d4f7801c657cc79d2243e1a81831334.zip |
Updated 32 files, added 279 files, deleted 3 files and renamed 14 files (automated)
Diffstat (limited to 'includes/process.js')
-rw-r--r-- | includes/process.js | 24 |
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..."); |