mirror of
https://github.com/MasterAcnolo/Freedom-Loader.git
synced 2026-07-29 18:25:47 +02:00
Notify Error + Cookies Gestion
This commit is contained in:
BIN
build/error.png
Normal file
BIN
build/error.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 13 KiB |
@@ -2,6 +2,6 @@ module.exports = {
|
|||||||
version: "1.3.0",
|
version: "1.3.0",
|
||||||
applicationPort: "8787",
|
applicationPort: "8787",
|
||||||
debugMode: true,
|
debugMode: true,
|
||||||
localMode: true,
|
localMode: false,
|
||||||
DiscordRPCID: "1410934537051181146",
|
DiscordRPCID: "1410934537051181146",
|
||||||
}
|
}
|
||||||
@@ -47,6 +47,10 @@
|
|||||||
"from": "build/confirm-icon.png",
|
"from": "build/confirm-icon.png",
|
||||||
"to": "confirm-icon.png"
|
"to": "confirm-icon.png"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"from": "build/error.png",
|
||||||
|
"to": "error.png"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"from": "ressources/yt-dlp.exe",
|
"from": "ressources/yt-dlp.exe",
|
||||||
"to": "yt-dlp.exe"
|
"to": "yt-dlp.exe"
|
||||||
|
|||||||
@@ -1,7 +1,10 @@
|
|||||||
const path = require("path");
|
const path = require("path");
|
||||||
|
|
||||||
|
const getUserBrowser = require("./getBrowser")
|
||||||
|
|
||||||
function buildYtDlpArgs({ url, audioOnly, quality, outputFolder }) {
|
function buildYtDlpArgs({ url, audioOnly, quality, outputFolder }) {
|
||||||
const args = [
|
const args = [
|
||||||
|
"--cookies-from-browser", `${getUserBrowser()}`,
|
||||||
"--no-continue",
|
"--no-continue",
|
||||||
"--no-overwrites",
|
"--no-overwrites",
|
||||||
"--embed-thumbnail",
|
"--embed-thumbnail",
|
||||||
@@ -32,3 +35,4 @@ function buildYtDlpArgs({ url, audioOnly, quality, outputFolder }) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
module.exports = { buildYtDlpArgs };
|
module.exports = { buildYtDlpArgs };
|
||||||
|
|
||||||
|
|||||||
27
server/helpers/getBrowser.js
Normal file
27
server/helpers/getBrowser.js
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
const fs = require("fs");
|
||||||
|
const os = require("os");
|
||||||
|
const path = require("path");
|
||||||
|
const notify = require("./notify")
|
||||||
|
|
||||||
|
function getUserBrowser() {
|
||||||
|
const userProfile = os.homedir();
|
||||||
|
|
||||||
|
// Liste des navigateurs supportés par yt-dlp
|
||||||
|
const browsers = [
|
||||||
|
{ name: "firefox", path: path.join(userProfile, "AppData", "Roaming", "Mozilla", "Firefox", "Profiles")},
|
||||||
|
{ name: "chrome", path: path.join(userProfile, "AppData", "Local", "Google", "Chrome", "User Data") },
|
||||||
|
{ name: "edge", path: path.join(userProfile, "AppData", "Local", "Microsoft", "Edge", "User Data") },
|
||||||
|
];
|
||||||
|
|
||||||
|
for (const browser of browsers) {
|
||||||
|
if (fs.existsSync(browser.path)) {
|
||||||
|
return browser.name;
|
||||||
|
} else{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
notify.notifyCookiesBrowserError()
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = getUserBrowser
|
||||||
@@ -13,4 +13,19 @@ function notifyDownloadFinished(folder) {
|
|||||||
notif.show();
|
notif.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = { notifyDownloadFinished };
|
function notifyCookiesBrowserError(){
|
||||||
|
const iconPath = path.join(process.resourcesPath, "error.png");
|
||||||
|
const notif = new Notification({
|
||||||
|
title: "Cookies Error",
|
||||||
|
body: "Impossible de récupérer les cookies. Connectez-vous sur votre navigateur et cliquez ici pour voir le tuto.",
|
||||||
|
icon: iconPath,
|
||||||
|
});
|
||||||
|
|
||||||
|
notif.on("click", () => shell.openExternal("https://youtube.com/shorts/cN9f4s1Mf88?si=519QCVd_-fzJqRf1"));
|
||||||
|
notif.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
notifyDownloadFinished,
|
||||||
|
notifyCookiesBrowserError
|
||||||
|
};
|
||||||
@@ -3,6 +3,8 @@ const router = express.Router();
|
|||||||
const { execFile } = require("child_process");
|
const { execFile } = require("child_process");
|
||||||
const { logger } = require("../logger");
|
const { logger } = require("../logger");
|
||||||
const { userYtDlp } = require("../helpers/path");
|
const { userYtDlp } = require("../helpers/path");
|
||||||
|
const getUserBrowser = require("../helpers/getBrowser")
|
||||||
|
|
||||||
|
|
||||||
// const ytDlpPath = path.join(__dirname, '../../ressources/yt-dlp.exe');
|
// const ytDlpPath = path.join(__dirname, '../../ressources/yt-dlp.exe');
|
||||||
// const userYtDlp = path.join(process.env.APPDATA || process.env.USERPROFILE, 'FreedomLoader', 'yt-dlp.exe');
|
// const userYtDlp = path.join(process.env.APPDATA || process.env.USERPROFILE, 'FreedomLoader', 'yt-dlp.exe');
|
||||||
@@ -22,9 +24,20 @@ router.post("/", (req, res) => {
|
|||||||
|
|
||||||
logger.info(`Requête /info reçue pour ${url}`);
|
logger.info(`Requête /info reçue pour ${url}`);
|
||||||
|
|
||||||
const args = ["--dump-single-json", "--ignore-errors", "--yes-playlist", url];
|
const args = ["--dump-single-json", "--ignore-errors", "--yes-playlist", url, "--cookies-from-browser" , `${getUserBrowser()}`];
|
||||||
|
|
||||||
execFile(userYtDlp, args, { timeout: 30_000, maxBuffer: 10 * 1024 * 1024 }, (error, stdout, stderr) => {
|
execFile(userYtDlp, args, { timeout: 30_000, maxBuffer: 10 * 1024 * 1024 }, (error, stdout, stderr) => {
|
||||||
|
|
||||||
|
if (stderr) {
|
||||||
|
const lower = stderr.toLowerCase();
|
||||||
|
if (lower.includes("sign in to confirm") || lower.includes("failed to decrypt") || lower.includes("could not copy")) {
|
||||||
|
const browser = getUserBrowser();
|
||||||
|
return res.status(400).send(
|
||||||
|
`❌ Impossible d'extraire les cookies depuis ${browser}. Connectez-vous dans ce navigateur et réessayez.`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
logger.error(`Erreur yt-dlp: ${error.message}`);
|
logger.error(`Erreur yt-dlp: ${error.message}`);
|
||||||
if (stderr) logger.debug(`stderr: ${stderr}`);
|
if (stderr) logger.debug(`stderr: ${stderr}`);
|
||||||
|
|||||||
Reference in New Issue
Block a user