Add yt-dlp version, path info

improved_format_select
aandrew-me 4 weeks ago
parent b1c6bc8e30
commit df4a90f6c9

@ -139,7 +139,7 @@
--blueBtn: #268bd2;
--blueBtn-bottom: #2074b1;
}
:root[theme = "gruvbox"]{
:root[theme="gruvbox"] {
--background: #242424;
--text: #fffefd;
--box-main: #32302f;
@ -148,13 +148,12 @@
--box-toggleOn: #458588;
--item-bg: #4d515d;
--select: #98971a;
--greenBtn:#8ec07c;
--greenBtn-bottom:#689D6A;
--greenBtn: #8ec07c;
--greenBtn-bottom: #689d6a;
--redBtn: #fb4934;
--redBtn-bottom: #cc241d;
--blueBtn: #7fa2ac;
--blueBtn-bottom: #458588;
}
body {
@ -163,8 +162,17 @@ body {
padding: 20px;
font-size: x-large;
text-align: left;
font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue",
font-family:
system-ui,
-apple-system,
BlinkMacSystemFont,
"Segoe UI",
Roboto,
Oxygen,
Ubuntu,
Cantarell,
"Open Sans",
"Helvetica Neue",
sans-serif;
}
h1 {
@ -182,8 +190,17 @@ input[type="text"],
border: none;
width: 50%;
height: 35px;
font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue",
font-family:
system-ui,
-apple-system,
BlinkMacSystemFont,
"Segoe UI",
Roboto,
Oxygen,
Ubuntu,
Cantarell,
"Open Sans",
"Helvetica Neue",
sans-serif;
}
.input {
@ -203,13 +220,31 @@ input[type="text"],
background-color: var(--box-main);
}
#ytDlpArgBox {
#ytdlpInfoBox {
margin: 15px 15px;
padding: 20px 15px;
border-radius: 15px;
background-color: var(--box-main);
}
#path {
.ytdlpInfoItem {
display: flex;
justify-content: space-between;
align-items: center;
margin: 5px 5px;
padding: 20px 15px;
background-color: var(--box-separation);
border-radius: 15px;
overflow: hidden;
}
#ytDlpArgBox {
margin: 5px 5px;
padding: 20px 15px;
border-radius: 15px;
background-color: var(--box-separation);
}
#path, .path {
font-family: "JetBrains";
font-size: medium;
}
@ -388,4 +423,4 @@ body::-webkit-scrollbar-thumb {
opacity: 1;
transition: opacity 0.4s;
}
}

@ -134,20 +134,33 @@
pattern="^(http:\/\/|https:\/\/|socks5:\/\/)?[a-zA-Z0-9.]+:[\d]+$">
</div>
<div class="prefBox">
<span id="ytdlpSourceTxt" data-translate="ytdlpSource">yt-dlp source</span>
<select id="ytdlpSource">
<option value="nightly" data-translate="ytdlpSourceNightly">Nightly (auto-updating)</option>
<option value="system" data-translate="ytdlpSourceSystem">System yt-dlp</option>
</select>
</div>
<div id="ytdlpInfoBox">
<div class="ytdlpInfoItem">
<span>yt-dlp version</span>
<span id="ytDlpVersion"></span>
</div>
<div class="ytdlpInfoItem">
<span id="ytDlpPathTxt" data-translate="ytDlpPath">yt-dlp path</span>
<span id="ytDlpPath" class="path"></span>
</div>
<div class="ytdlpInfoItem" id="ytdlpSourceBox">
<span id="ytdlpSourceTxt" data-translate="ytdlpSource">yt-dlp source</span>
<select id="ytdlpSource">
<option value="nightly" data-translate="ytdlpSourceNightly">Nightly (auto-updating)</option>
<option value="system" data-translate="ytdlpSourceSystem">System yt-dlp</option>
</select>
</div>
<div id="ytDlpArgBox">
<p>
<span data-translate="customArgsTxt">Set custom yt-dlp arguments.</span>
<a data-translate="learnMore" id="learnMoreLink">Learn more</a>
</p>
<textarea spellcheck="false" id="customArgsInput" placeholder="--sponsorblock-remove all"></textarea>
</div>
<div id="ytDlpArgBox">
<p>
<span data-translate="customArgsTxt">Set custom yt-dlp arguments.</span>
<a data-translate="learnMore" id="learnMoreLink">Learn more</a>
</p>
<textarea spellcheck="false" id="customArgsInput" placeholder="--sponsorblock-remove all"></textarea>
</div>
<div id="pathConfig">

@ -1,7 +1,8 @@
const {ipcRenderer, shell} = require("electron");
const {accessSync, constants} = require("original-fs");
const {join} = require("path");
const {homedir} = require("os");
const {homedir, platform} = require("os");
const {exec} = require("child_process");
const storageTheme = localStorage.getItem("theme");
if (storageTheme) {
@ -29,6 +30,68 @@ if (rightToLeft == "true") {
});
}
// Check yt-dlp version
// Execute the yt-dlp --version command with childprocess exec command
const ytdlpPath = localStorage.getItem("ytdlp");
console.log("yt-dlp path:", ytdlpPath);
if (ytdlpPath) {
exec(`"${ytdlpPath}" --version`, (error, stdout, _stderr) => {
if (error) {
console.error("Error executing yt-dlp:", error);
} else {
const version = stdout.trim();
console.log("yt-dlp version:", version);
document.getElementById("ytDlpVersion").textContent = version;
document.getElementById("ytDlpPath").textContent = ytdlpPath;
}
});
} else {
let systemPath;
if (platform() === "win32") {
exec("where yt-dlp", (err, stdout) => {
if (err) {
console.error("Error finding yt-dlp:", err);
return;
}
systemPath = stdout.trim().split("\n")[0];
console.log("System yt-dlp path:", systemPath);
exec(`"${systemPath}" --version`, (error, stdout, _stderr) => {
if (error) {
console.error("Error executing yt-dlp:", error);
} else {
const version = stdout.trim();
console.log("yt-dlp version:", version);
document.getElementById("ytDlpVersion").textContent =
version;
document.getElementById("ytDlpPath").textContent =
systemPath;
}
});
});
} else {
// for Unix-like systems including macos, use 'which' command to find yt-dlp
exec("which yt-dlp", (err, stdout) => {
if (err) {
console.error("Error finding yt-dlp:", err);
return;
}
systemPath = stdout.trim();
console.log("System yt-dlp path:", systemPath);
exec(`"${systemPath}" --version`, (error, stdout, _stderr) => {
if (error) {
console.error("Error executing yt-dlp:", error);
}
const version = stdout.trim();
console.log("yt-dlp version:", version);
document.getElementById("ytDlpVersion").textContent = version;
});
});
}
}
// Download path
let downloadPath = localStorage.getItem("downloadPath");
@ -54,7 +117,7 @@ document.addEventListener("translations-loaded", () => {
if (process.env.FLATPAK_ID) {
getId("flatpakTxt").addEventListener("click", () => {
shell.openExternal(
"https://flathub.org/apps/com.github.tchx84.Flatseal"
"https://flathub.org/apps/com.github.tchx84.Flatseal",
);
});
@ -148,16 +211,22 @@ getId("browser").addEventListener("change", () => {
});
// yt-dlp source (nightly app-managed binary vs system yt-dlp)
let ytdlpSource = localStorage.getItem("ytdlpSource") || "nightly";
getId("ytdlpSource").value = ytdlpSource;
getId("ytdlpSource").addEventListener("change", () => {
ytdlpSource = getId("ytdlpSource").value;
localStorage.setItem("ytdlpSource", ytdlpSource);
// Drop the cached path so the new source is resolved on reload.
localStorage.removeItem("ytdlp");
// Reload so renderer re-resolves the yt-dlp binary for the new source.
ipcRenderer.send("reload");
});
if (platform() === "darwin") {
getId("ytdlpSourceBox").style.display = "none";
} else {
const ytdlpSource = localStorage.getItem("ytdlpSource") || "nightly";
const ytdlpSourceSelect = getId("ytdlpSource");
ytdlpSourceSelect.value = ytdlpSource;
ytdlpSourceSelect.addEventListener("change", () => {
localStorage.setItem("ytdlpSource", ytdlpSourceSelect.value);
// Drop the cached path so the new source is resolved on reload.
localStorage.removeItem("ytdlp");
// Reload so renderer re-resolves the yt-dlp binary for the new source.
ipcRenderer.send("reload");
});
}
// Handling preferred video quality
let preferredVideoQuality = localStorage.getItem("preferredVideoQuality");
@ -218,7 +287,7 @@ ytDlpArgsInput.addEventListener("input", () => {
getId("learnMoreLink").addEventListener("click", () => {
shell.openExternal(
"https://github.com/aandrew-me/ytDownloader/wiki/Custom-yt%E2%80%90dlp-options"
"https://github.com/aandrew-me/ytDownloader/wiki/Custom-yt%E2%80%90dlp-options",
);
});
@ -244,7 +313,7 @@ getId("resetFilenameFormat").addEventListener("click", () => {
getId("filenameFormat").value = "%(playlist_index)s.%(title)s.%(ext)s";
localStorage.setItem(
"filenameFormat",
"%(playlist_index)s.%(title)s.%(ext)s"
"%(playlist_index)s.%(title)s.%(ext)s",
);
});

@ -343,9 +343,17 @@ class YtDownloaderApp {
// managed binary if nothing is found in PATH.
if (source === CONSTANTS.YT_DLP_SOURCE.SYSTEM) {
try {
const systemPath = execSync("command -v yt-dlp")
.toString()
.trim();
let systemPath;
if (platform() === "win32") {
systemPath = execSync("where yt-dlp")
.toString()
.split(/\r?\n/)[0]
.trim();
} else {
systemPath = execSync("command -v yt-dlp")
.toString()
.trim();
}
if (systemPath && existsSync(systemPath)) {
executablePath = systemPath;
}
@ -420,10 +428,6 @@ class YtDownloaderApp {
return;
}
// Release channel for the self-managed binary.
// "nightly" gets YouTube fixes days before stable; switching
// the channel also keeps the binary on the latest nightly on
// every launch. Set to "stable" to track stable releases.
const releaseChannel = "nightly";
const updateProc = spawn(executablePath, [

@ -1,7 +1,7 @@
{
"compilerOptions": {
"allowJs": true,
"checkJs": true,
"checkJs": false,
"lib": [
"ES2021.String",
"DOM",

Loading…
Cancel
Save