From baa393163962ecc885d5cb3323d8951627c40d7e Mon Sep 17 00:00:00 2001 From: aandrew-me Date: Fri, 14 Nov 2025 21:49:07 +0300 Subject: [PATCH] Download progress for yt-dlp download and improved error handling --- html/index.html | 1 + package-lock.json | 12 ++++++------ package.json | 2 +- src/renderer.js | 21 ++++++++++++++++++++- 4 files changed, 28 insertions(+), 8 deletions(-) diff --git a/html/index.html b/html/index.html index c8421bf..e1bbcc3 100644 --- a/html/index.html +++ b/html/index.html @@ -32,6 +32,7 @@ +

diff --git a/package-lock.json b/package-lock.json index 99aa92a..b44ea89 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,17 +1,17 @@ { "name": "ytdownloader", - "version": "3.19.2", + "version": "3.20.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "ytdownloader", - "version": "3.19.2", + "version": "3.20.0", "license": "GPL-3.0", "dependencies": { "electron-updater": "^6.6.2", "systeminformation": "^5.25.11", - "yt-dlp-wrap-plus": "^2.3.20" + "yt-dlp-wrap-plus": "^2.4.3" }, "devDependencies": { "electron": "^30.0.0", @@ -5122,9 +5122,9 @@ } }, "node_modules/yt-dlp-wrap-plus": { - "version": "2.3.20", - "resolved": "https://registry.npmjs.org/yt-dlp-wrap-plus/-/yt-dlp-wrap-plus-2.3.20.tgz", - "integrity": "sha512-vKQfQMvvSbTta+mrRrMFYm+e/vkbHK5X9L2LiO3JRVHUmEjzpk8qdFpQwp27FPIA7nLR17AZA5gG9yEVcF3avQ==", + "version": "2.4.3", + "resolved": "https://registry.npmjs.org/yt-dlp-wrap-plus/-/yt-dlp-wrap-plus-2.4.3.tgz", + "integrity": "sha512-D/Q1/gipu8hEmairp5gRyWQE+BsfJanALbkzTxWdTC/LRXlCq00vDdscFxvVrypXT5UGf6KP1gtrKFV087uCEw==", "license": "MIT" } } diff --git a/package.json b/package.json index 34824cf..8b6f72d 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "dependencies": { "electron-updater": "^6.6.2", "systeminformation": "^5.25.11", - "yt-dlp-wrap-plus": "^2.3.20" + "yt-dlp-wrap-plus": "^2.4.3" }, "name": "ytdownloader", "version": "3.20.0", diff --git a/src/renderer.js b/src/renderer.js index cb62bf8..bb81833 100644 --- a/src/renderer.js +++ b/src/renderer.js @@ -50,6 +50,7 @@ const CONSTANTS = { POPUP_BOX_MAC: "popupBoxMac", POPUP_TEXT: "popupText", POPUP_SVG: "popupSvg", + YTDLP_DOWNLOAD_PROGRESS: "ytDlpDownloadProgress", // Menu MENU_ICON: "menuIcon", MENU: "menu", @@ -379,19 +380,37 @@ class YtDownloaderApp { ); 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"; + localStorage.setItem( CONSTANTS.LOCAL_STORAGE_KEYS.YT_DLP_PATH, defaultYtDlpPath ); + return defaultYtDlpPath; } catch (downloadError) { + $(CONSTANTS.DOM_IDS.YTDLP_DOWNLOAD_PROGRESS).textContent = ""; + console.error("Failed to download yt-dlp:", downloadError); + document.querySelector("#popupBox p").textContent = i18n.__( "errorFailedFileDownload" ); $(CONSTANTS.DOM_IDS.POPUP_SVG).style.display = "none"; + throw new Error("Failed to download yt-dlp."); } }