Download progress for yt-dlp download and improved error handling

pull/354/head
aandrew-me 2 weeks ago
parent 23e3ee35e8
commit baa3931639

@ -32,6 +32,7 @@
<animate attributeName="opacity" dur="1s" values="0;1;0" repeatCount="indefinite" begin="0.3" /> <animate attributeName="opacity" dur="1s" values="0;1;0" repeatCount="indefinite" begin="0.3" />
</circle> </circle>
</svg> </svg>
<p id="ytDlpDownloadProgress"></p>
</div> </div>
</div> </div>

12
package-lock.json generated

@ -1,17 +1,17 @@
{ {
"name": "ytdownloader", "name": "ytdownloader",
"version": "3.19.2", "version": "3.20.0",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "ytdownloader", "name": "ytdownloader",
"version": "3.19.2", "version": "3.20.0",
"license": "GPL-3.0", "license": "GPL-3.0",
"dependencies": { "dependencies": {
"electron-updater": "^6.6.2", "electron-updater": "^6.6.2",
"systeminformation": "^5.25.11", "systeminformation": "^5.25.11",
"yt-dlp-wrap-plus": "^2.3.20" "yt-dlp-wrap-plus": "^2.4.3"
}, },
"devDependencies": { "devDependencies": {
"electron": "^30.0.0", "electron": "^30.0.0",
@ -5122,9 +5122,9 @@
} }
}, },
"node_modules/yt-dlp-wrap-plus": { "node_modules/yt-dlp-wrap-plus": {
"version": "2.3.20", "version": "2.4.3",
"resolved": "https://registry.npmjs.org/yt-dlp-wrap-plus/-/yt-dlp-wrap-plus-2.3.20.tgz", "resolved": "https://registry.npmjs.org/yt-dlp-wrap-plus/-/yt-dlp-wrap-plus-2.4.3.tgz",
"integrity": "sha512-vKQfQMvvSbTta+mrRrMFYm+e/vkbHK5X9L2LiO3JRVHUmEjzpk8qdFpQwp27FPIA7nLR17AZA5gG9yEVcF3avQ==", "integrity": "sha512-D/Q1/gipu8hEmairp5gRyWQE+BsfJanALbkzTxWdTC/LRXlCq00vDdscFxvVrypXT5UGf6KP1gtrKFV087uCEw==",
"license": "MIT" "license": "MIT"
} }
} }

@ -2,7 +2,7 @@
"dependencies": { "dependencies": {
"electron-updater": "^6.6.2", "electron-updater": "^6.6.2",
"systeminformation": "^5.25.11", "systeminformation": "^5.25.11",
"yt-dlp-wrap-plus": "^2.3.20" "yt-dlp-wrap-plus": "^2.4.3"
}, },
"name": "ytdownloader", "name": "ytdownloader",
"version": "3.20.0", "version": "3.20.0",

@ -50,6 +50,7 @@ const CONSTANTS = {
POPUP_BOX_MAC: "popupBoxMac", POPUP_BOX_MAC: "popupBoxMac",
POPUP_TEXT: "popupText", POPUP_TEXT: "popupText",
POPUP_SVG: "popupSvg", POPUP_SVG: "popupSvg",
YTDLP_DOWNLOAD_PROGRESS: "ytDlpDownloadProgress",
// Menu // Menu
MENU_ICON: "menuIcon", MENU_ICON: "menuIcon",
MENU: "menu", MENU: "menu",
@ -379,19 +380,37 @@ class YtDownloaderApp {
); );
try { try {
await YTDlpWrap.downloadFromGithub(defaultYtDlpPath); await YTDlpWrap.downloadFromGithub(
defaultYtDlpPath,
undefined,
undefined,
(progress, _d, _t) => {
$(
CONSTANTS.DOM_IDS.YTDLP_DOWNLOAD_PROGRESS
).textContent =
i18n.__("progress") +
`: ${(progress * 100).toFixed(2)}%`;
}
);
$(CONSTANTS.DOM_IDS.POPUP_BOX).style.display = "none"; $(CONSTANTS.DOM_IDS.POPUP_BOX).style.display = "none";
localStorage.setItem( localStorage.setItem(
CONSTANTS.LOCAL_STORAGE_KEYS.YT_DLP_PATH, CONSTANTS.LOCAL_STORAGE_KEYS.YT_DLP_PATH,
defaultYtDlpPath defaultYtDlpPath
); );
return defaultYtDlpPath; return defaultYtDlpPath;
} catch (downloadError) { } catch (downloadError) {
$(CONSTANTS.DOM_IDS.YTDLP_DOWNLOAD_PROGRESS).textContent = "";
console.error("Failed to download yt-dlp:", downloadError); console.error("Failed to download yt-dlp:", downloadError);
document.querySelector("#popupBox p").textContent = i18n.__( document.querySelector("#popupBox p").textContent = i18n.__(
"errorFailedFileDownload" "errorFailedFileDownload"
); );
$(CONSTANTS.DOM_IDS.POPUP_SVG).style.display = "none"; $(CONSTANTS.DOM_IDS.POPUP_SVG).style.display = "none";
throw new Error("Failed to download yt-dlp."); throw new Error("Failed to download yt-dlp.");
} }
} }

Loading…
Cancel
Save