Refactoring fix
This commit is contained in:
parent
118dd31120
commit
1e7d967f2b
@ -733,7 +733,7 @@ body::-webkit-scrollbar-thumb {
|
|||||||
|
|
||||||
.container {
|
.container {
|
||||||
max-width: 800px;
|
max-width: 800px;
|
||||||
margin: 0 auto 10px auto;
|
margin: 30px auto 10px auto;
|
||||||
background: var(--box-main);
|
background: var(--box-main);
|
||||||
padding: 30px;
|
padding: 30px;
|
||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
@ -778,7 +778,7 @@ body::-webkit-scrollbar-thumb {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#output-folder-box {
|
#output-folder-box {
|
||||||
background-color: var(--item-bg);
|
background-color: var(--box-toggle);
|
||||||
margin-bottom: 12px;
|
margin-bottom: 12px;
|
||||||
padding: 15px;
|
padding: 15px;
|
||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
|
@ -9,6 +9,9 @@
|
|||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body id="compressor_body">
|
<body id="compressor_body">
|
||||||
|
<!-- Popup message -->
|
||||||
|
<span id="popupText">Text copied</span>
|
||||||
|
|
||||||
<!-- Menu icon -->
|
<!-- Menu icon -->
|
||||||
<img src="../assets/images/menu.png" alt="menu" id="menuIcon">
|
<img src="../assets/images/menu.png" alt="menu" id="menuIcon">
|
||||||
|
|
||||||
@ -48,7 +51,7 @@
|
|||||||
<option value="unchanged">Unchanged</option>
|
<option value="unchanged">Unchanged</option>
|
||||||
<option value="mp4">mp4</option>
|
<option value="mp4">mp4</option>
|
||||||
<option value="mkv">mkv</option>
|
<option value="mkv">mkv</option>
|
||||||
<option value="webm">webm</option>
|
<!-- <option value="webm">webm</option> -->
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -135,7 +138,7 @@
|
|||||||
<option value="copy">Unchanged</option>
|
<option value="copy">Unchanged</option>
|
||||||
<option value="aac">aac</option>
|
<option value="aac">aac</option>
|
||||||
<option value="mp3">mp3</option>
|
<option value="mp3">mp3</option>
|
||||||
<option value="opus">opus</option>
|
<!-- <option value="libopus">opus</option> -->
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -21,6 +21,7 @@ getId("menuIcon").addEventListener("click", () => {
|
|||||||
getId("menu").style.display = "none";
|
getId("menu").style.display = "none";
|
||||||
clearInterval(fade);
|
clearInterval(fade);
|
||||||
} else {
|
} else {
|
||||||
|
opacity -= 0.1;
|
||||||
getId("menu").style.opacity = opacity.toFixed(3).toString();
|
getId("menu").style.opacity = opacity.toFixed(3).toString();
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
@ -31,7 +32,7 @@ getId("menuIcon").addEventListener("click", () => {
|
|||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
getId("menu").style.display = "flex";
|
getId("menu").style.display = "flex";
|
||||||
getId("menu").style.opacity = 1;
|
getId("menu").style.opacity = "1";
|
||||||
}, 150);
|
}, 150);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -37,7 +37,15 @@ getId("menuIcon").addEventListener("click", () => {
|
|||||||
let ffmpeg;
|
let ffmpeg;
|
||||||
if (os.platform() === "win32") {
|
if (os.platform() === "win32") {
|
||||||
ffmpeg = `"${__dirname}\\..\\ffmpeg.exe"`;
|
ffmpeg = `"${__dirname}\\..\\ffmpeg.exe"`;
|
||||||
} else {
|
} else if (os.platform() === "freebsd") {
|
||||||
|
try {
|
||||||
|
ffmpeg = cp.execSync("which ffmpeg").toString("utf8").split("\n")[0].trim();
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error)
|
||||||
|
showPopup("No ffmpeg found in PATH.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
ffmpeg = `"${__dirname}/../ffmpeg"`;
|
ffmpeg = `"${__dirname}/../ffmpeg"`;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -304,6 +312,7 @@ function buildFFmpegCommand(file, settings, outputPath) {
|
|||||||
"libx264",
|
"libx264",
|
||||||
"-preset",
|
"-preset",
|
||||||
settings.speed,
|
settings.speed,
|
||||||
|
"-vf", "format=yuv420p",
|
||||||
"-crf",
|
"-crf",
|
||||||
parseInt(settings.videoQuality).toString()
|
parseInt(settings.videoQuality).toString()
|
||||||
);
|
);
|
||||||
@ -312,6 +321,7 @@ function buildFFmpegCommand(file, settings, outputPath) {
|
|||||||
args.push(
|
args.push(
|
||||||
"-c:v",
|
"-c:v",
|
||||||
"libx265",
|
"libx265",
|
||||||
|
"-vf", "format=yuv420p",
|
||||||
"-preset",
|
"-preset",
|
||||||
settings.speed,
|
settings.speed,
|
||||||
"-crf",
|
"-crf",
|
||||||
@ -323,6 +333,7 @@ function buildFFmpegCommand(file, settings, outputPath) {
|
|||||||
args.push(
|
args.push(
|
||||||
"-c:v",
|
"-c:v",
|
||||||
"h264_qsv",
|
"h264_qsv",
|
||||||
|
"-vf", "format=yuv420p",
|
||||||
"-preset",
|
"-preset",
|
||||||
settings.speed,
|
settings.speed,
|
||||||
"-global_quality",
|
"-global_quality",
|
||||||
@ -359,6 +370,7 @@ function buildFFmpegCommand(file, settings, outputPath) {
|
|||||||
args.push(
|
args.push(
|
||||||
"-c:v",
|
"-c:v",
|
||||||
"h264_nvenc",
|
"h264_nvenc",
|
||||||
|
"-vf", "format=yuv420p",
|
||||||
"-preset",
|
"-preset",
|
||||||
getNvencPreset(settings.speed),
|
getNvencPreset(settings.speed),
|
||||||
"-rc",
|
"-rc",
|
||||||
@ -380,6 +392,7 @@ function buildFFmpegCommand(file, settings, outputPath) {
|
|||||||
args.push(
|
args.push(
|
||||||
"-c:v",
|
"-c:v",
|
||||||
"hevc_amf",
|
"hevc_amf",
|
||||||
|
"-vf", "format=yuv420p",
|
||||||
"-quality",
|
"-quality",
|
||||||
amf_hevc_quality,
|
amf_hevc_quality,
|
||||||
"-rc",
|
"-rc",
|
||||||
@ -402,6 +415,7 @@ function buildFFmpegCommand(file, settings, outputPath) {
|
|||||||
args.push(
|
args.push(
|
||||||
"-c:v",
|
"-c:v",
|
||||||
"h264_amf",
|
"h264_amf",
|
||||||
|
"-vf", "format=yuv420p",
|
||||||
"-quality",
|
"-quality",
|
||||||
amf_quality,
|
amf_quality,
|
||||||
"-rc",
|
"-rc",
|
||||||
@ -417,6 +431,7 @@ function buildFFmpegCommand(file, settings, outputPath) {
|
|||||||
case "videotoolbox":
|
case "videotoolbox":
|
||||||
args.push(
|
args.push(
|
||||||
"-c:v",
|
"-c:v",
|
||||||
|
"-vf", "format=yuv420p",
|
||||||
"h264_videotoolbox",
|
"h264_videotoolbox",
|
||||||
"-q:v",
|
"-q:v",
|
||||||
parseInt(settings.videoQuality).toString()
|
parseInt(settings.videoQuality).toString()
|
||||||
@ -426,8 +441,6 @@ function buildFFmpegCommand(file, settings, outputPath) {
|
|||||||
|
|
||||||
// args.push("-vf", "scale=trunc(iw*1/2)*2:trunc(ih*1/2)*2,format=yuv420p");
|
// args.push("-vf", "scale=trunc(iw*1/2)*2:trunc(ih*1/2)*2,format=yuv420p");
|
||||||
|
|
||||||
args.push("-vf", "format=yuv420p");
|
|
||||||
|
|
||||||
args.push("-c:a", settings.audioFormat, `"${outputPath}"`);
|
args.push("-c:a", settings.audioFormat, `"${outputPath}"`);
|
||||||
|
|
||||||
return `${ffmpeg} ${args.join(" ")}`;
|
return `${ffmpeg} ${args.join(" ")}`;
|
||||||
@ -499,7 +512,7 @@ function createProgressItem(filename, status, data, itemId) {
|
|||||||
<div class="filename">${visibleFilename}</div>
|
<div class="filename">${visibleFilename}</div>
|
||||||
<div id="${itemId + "_prog"}" class="itemProgress">${data}</div>
|
<div id="${itemId + "_prog"}" class="itemProgress">${data}</div>
|
||||||
`;
|
`;
|
||||||
statusElement.prepend(newStatus);
|
statusElement.append(newStatus);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -528,21 +541,6 @@ function timeToSeconds(timeStr) {
|
|||||||
return hh * 3600 + mm * 60 + ss;
|
return hh * 3600 + mm * 60 + ss;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Menu
|
|
||||||
getId("preferenceWin").addEventListener("click", () => {
|
|
||||||
closeMenu();
|
|
||||||
ipcRenderer.send("load-page", __dirname + "/preferences.html");
|
|
||||||
});
|
|
||||||
|
|
||||||
getId("aboutWin").addEventListener("click", () => {
|
|
||||||
closeMenu();
|
|
||||||
ipcRenderer.send("load-page", __dirname + "/about.html");
|
|
||||||
});
|
|
||||||
getId("homeWin").addEventListener("click", () => {
|
|
||||||
closeMenu();
|
|
||||||
ipcRenderer.send("load-win", __dirname + "/index.html");
|
|
||||||
});
|
|
||||||
|
|
||||||
getId("themeToggle").addEventListener("change", () => {
|
getId("themeToggle").addEventListener("change", () => {
|
||||||
document.documentElement.setAttribute("theme", getId("themeToggle").value);
|
document.documentElement.setAttribute("theme", getId("themeToggle").value);
|
||||||
localStorage.setItem("theme", getId("themeToggle").value);
|
localStorage.setItem("theme", getId("themeToggle").value);
|
||||||
@ -591,19 +589,33 @@ function closeMenu() {
|
|||||||
// Menu
|
// Menu
|
||||||
getId("preferenceWin").addEventListener("click", () => {
|
getId("preferenceWin").addEventListener("click", () => {
|
||||||
closeMenu();
|
closeMenu();
|
||||||
|
menuIsOpen = false;
|
||||||
ipcRenderer.send("load-page", __dirname + "/preferences.html");
|
ipcRenderer.send("load-page", __dirname + "/preferences.html");
|
||||||
});
|
});
|
||||||
|
|
||||||
getId("playlistWin").addEventListener("click", () => {
|
getId("playlistWin").addEventListener("click", () => {
|
||||||
closeMenu();
|
closeMenu();
|
||||||
|
menuIsOpen = false;
|
||||||
ipcRenderer.send("load-win", __dirname + "/playlist.html");
|
ipcRenderer.send("load-win", __dirname + "/playlist.html");
|
||||||
});
|
});
|
||||||
|
|
||||||
getId("aboutWin").addEventListener("click", () => {
|
getId("aboutWin").addEventListener("click", () => {
|
||||||
closeMenu();
|
closeMenu();
|
||||||
|
menuIsOpen = false;
|
||||||
ipcRenderer.send("load-page", __dirname + "/about.html");
|
ipcRenderer.send("load-page", __dirname + "/about.html");
|
||||||
});
|
});
|
||||||
getId("homeWin").addEventListener("click", () => {
|
getId("homeWin").addEventListener("click", () => {
|
||||||
closeMenu();
|
closeMenu();
|
||||||
|
menuIsOpen = false;
|
||||||
ipcRenderer.send("load-win", __dirname + "/index.html");
|
ipcRenderer.send("load-win", __dirname + "/index.html");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Popup message
|
||||||
|
function showPopup(text) {
|
||||||
|
console.log("Triggered showpopup");
|
||||||
|
getId("popupText").textContent = text;
|
||||||
|
getId("popupText").style.display = "inline-block";
|
||||||
|
setTimeout(() => {
|
||||||
|
getId("popupText").style.display = "none";
|
||||||
|
}, 2200);
|
||||||
|
}
|
@ -306,12 +306,12 @@ function download(type) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
getId("finishBtn").addEventListener("click", () => {
|
// getId("finishBtn").addEventListener("click", () => {
|
||||||
controller.abort("user_finished")
|
// controller.abort("user_finished")
|
||||||
try {
|
// try {
|
||||||
process.kill(downloadProcess.ytDlpProcess.pid, 'SIGINT')
|
// process.kill(downloadProcess.ytDlpProcess.pid, 'SIGINT')
|
||||||
} catch (_error) {}
|
// } catch (_error) {}
|
||||||
})
|
// })
|
||||||
|
|
||||||
downloadProcess.on("ytDlpEvent", (_eventType, eventData) => {
|
downloadProcess.on("ytDlpEvent", (_eventType, eventData) => {
|
||||||
// console.log(eventData);
|
// console.log(eventData);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user