Settings update
This commit is contained in:
parent
b20bd0087c
commit
ca2700a20a
1 changed files with 34 additions and 29 deletions
63
lib/ui.js
63
lib/ui.js
|
@ -20,14 +20,12 @@ class UI {
|
||||||
}, cliProgress.Presets.shades_grey)
|
}, cliProgress.Presets.shades_grey)
|
||||||
|
|
||||||
this.settings = settings
|
this.settings = settings
|
||||||
this.currentSetting = currentSetting
|
|
||||||
this.settingsFile = settingsFile
|
this.settingsFile = settingsFile
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param {Number} duration Duration of the encoded media
|
* @param {Number} duration Duration of the encoded media
|
||||||
* @param {String} filename name of the encoding file
|
* @param {String} filename name of the encoding file
|
||||||
* @param {Boolean} isTwoPass is the encoded media two pass
|
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
async newBar(encoderOutput) {
|
async newBar(encoderOutput) {
|
||||||
|
@ -36,7 +34,6 @@ class UI {
|
||||||
let isTwoPass = encoderOutput[2]
|
let isTwoPass = encoderOutput[2]
|
||||||
this.bars.push({
|
this.bars.push({
|
||||||
"bar": this.multibar.create(duration, 0, { speed: "N/A" }),
|
"bar": this.multibar.create(duration, 0, { speed: "N/A" }),
|
||||||
"isTwoPass": isTwoPass,
|
|
||||||
"isPastHalf": false,
|
"isPastHalf": false,
|
||||||
"filename": filename,
|
"filename": filename,
|
||||||
"duration": duration,
|
"duration": duration,
|
||||||
|
@ -61,16 +58,11 @@ class UI {
|
||||||
const arr = currentTime.split(":")
|
const arr = currentTime.split(":")
|
||||||
let seconds = Number.parseFloat(arr[0] * 3600 + arr[1] * 60 + (+arr[2])) // converting to s
|
let seconds = Number.parseFloat(arr[0] * 3600 + arr[1] * 60 + (+arr[2])) // converting to s
|
||||||
|
|
||||||
//If 2 pass divide bar into two parts to show both in progress in one progress
|
if (seconds / 2 >= (this.bars[barIndex].duration - 0.2) / 2) this.bars[barIndex].isPastHalf = true
|
||||||
if (this.bars[barIndex].isTwoPass) {
|
|
||||||
if (seconds / 2 >= (this.bars[barIndex].duration - 0.2) / 2) this.bars[barIndex].isPastHalf = true
|
if (this.bars[barIndex].isPastHalf) this.bars[barIndex].bar.update(Math.round(seconds * 50) / 100 + (this.bars[barIndex].duration / 2), { filename: `${this.bars[barIndex].filename}.webm` })
|
||||||
|
else this.bars[barIndex].bar.update(Math.round(seconds * 50) / 100, { filename: `${this.bars[barIndex].filename}.webm` })
|
||||||
|
|
||||||
if (this.bars[barIndex].isPastHalf) this.bars[barIndex].bar.update(Math.round(seconds * 50) / 100 + (this.bars[barIndex].duration / 2), { filename: `${this.bars[barIndex].filename}.webm` })
|
|
||||||
else this.bars[barIndex].bar.update(Math.round(seconds * 50) / 100, { filename: `${this.bars[barIndex].filename}.webm` })
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
this.bars[barIndex].bar.update(Math.round(seconds * 100) / 100, { filename: `${this.bars[barIndex].filename}.webm` })
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
const currentTime = chunk.split("time=")[1]?.split(" ")[0]
|
const currentTime = chunk.split("time=")[1]?.split(" ")[0]
|
||||||
|
@ -100,23 +92,36 @@ class UI {
|
||||||
async startMenu() {
|
async startMenu() {
|
||||||
await this.#menu()
|
await this.#menu()
|
||||||
}
|
}
|
||||||
async #menu() {
|
#menu() {
|
||||||
let menu = []
|
return new Promise(resolve => {
|
||||||
for (let i = 0; i < this.settings.presets.length; i++) {
|
const menu = ["8 Megabytes", "50 Megabytes (Nitro Classic)", "100 Megabytes (Nitro)"]
|
||||||
menu.push(`${i}. ${this.settings.presets[i].name}`)
|
this.term.grey("How to convert: 8mb [filename.extension(s)]\n")
|
||||||
}
|
this.term.grey("examples: \n")
|
||||||
this.term.grey("How to convert: 8mb [optional: -preset {Index}] [filename.extension(s)]\n")
|
this.term.italic.grey(" 8mb -preset 0 file.mp3 file4.mov img.jpg\n")
|
||||||
this.term.grey("examples: \n")
|
this.term.italic.grey(" 8mb file34.wav file2.mp3\n\n")
|
||||||
this.term.italic.grey(" 8mb -preset 0 file.mp3 file4.mov img.jpg\n")
|
this.term.yellow("Hello! This menu is for selecting filesize limit (if using discord nitro)\n")
|
||||||
this.term.italic.grey(" 8mb file34.wav file2.mp3\n\n")
|
this.term.yellow("Currently using ").bgMagenta(`${this.settings.size_limit / 8000} Mb`).yellow(" filesize limit\n")
|
||||||
this.term.yellow("Hello! This menu is for selecting performance/speed preset.\n")
|
this.term.singleColumnMenu(menu, (error, response) => {
|
||||||
this.term.yellow("Currently using ").bgMagenta(`"${this.settings.presets[this.settings.currentSetting].name}"`).yellow(" preset\n")
|
switch (response.selectedIndex) {
|
||||||
this.term.singleColumnMenu(menu, (error, response) => {
|
case 0:
|
||||||
this.settings.currentSetting = response.selectedIndex
|
this.settings.size_limit = 64000
|
||||||
this.term.green("\n Using").green.bold(` ${this.settings.presets[this.settings.currentSetting].name} `).green("setting\n")
|
break
|
||||||
fs.writeFileSync(path.resolve(this.settingsFile, "settings.json"), JSON.stringify(this.settings))
|
case 1:
|
||||||
this.term.grey("Press enter to exit...")
|
this.settings.size_limit = 400000
|
||||||
this.term.inputField(() => { process.exit() })
|
break
|
||||||
|
case 2:
|
||||||
|
this.settings.size_limit = 800000
|
||||||
|
break
|
||||||
|
default:
|
||||||
|
this.settings.size_limit = 64000
|
||||||
|
break
|
||||||
|
}
|
||||||
|
this.term.green("\n Using").green.bold(` ${this.settings.size_limit / 8000} Mb `).green("setting\n")
|
||||||
|
fs.writeFileSync(path.resolve(this.settingsFile, "settings.json"), JSON.stringify(this.settings))
|
||||||
|
this.term.grey("Press enter to exit...")
|
||||||
|
this.term.inputField(() => { process.exit() })
|
||||||
|
resolve()
|
||||||
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue