Fix: Improve browser detection logging and error handling

This commit is contained in:
MasterAcnolo
2026-02-17 21:29:51 +01:00
parent 760550e521
commit fdb22f2342

View File

@@ -2,6 +2,7 @@ const fs = require("fs");
const os = require("os"); const os = require("os");
const path = require("path"); const path = require("path");
const notify = require("./notify") const notify = require("./notify")
const { logger } = require("../logger");
function getUserBrowser() { function getUserBrowser() {
const userProfile = os.homedir(); const userProfile = os.homedir();
@@ -18,15 +19,21 @@ function getUserBrowser() {
// { name: "whale", path: path.join(userProfile, "AppData", "Local", "Naver", "Naver Whale", "User Data", "Default") } // { name: "whale", path: path.join(userProfile, "AppData", "Local", "Naver", "Naver Whale", "User Data", "Default") }
]; ];
// Chercher un navigateur disponible
for (const browser of browsers) { for (const browser of browsers) {
if (fs.existsSync(browser.path)) { if (fs.existsSync(browser.path)) {
logger.info(`Browser found: ${browser.name}`);
return browser.name; return browser.name;
} else{ }
}
// Aucun navigateur trouvé - notifier l'utilisateur
logger.warn("No supported browser found on the system");
notify.notifyFirefoxBrowserMissing(); notify.notifyFirefoxBrowserMissing();
}
} // Fallback: retourner "firefox" pour laisser yt-dlp gérer l'erreur
notify.notifyCookiesBrowserError() // plutôt que de crasher l'application
return ; return "firefox";
} }
module.exports = getUserBrowser module.exports = getUserBrowser