Removed Cyberpunk | Spicy | Vilbrequin Theme, Info Fix, Fix Progress Bar. Centralized Ressources

This commit is contained in:
MasterAcnolo
2025-11-14 23:41:03 +01:00
parent c2e4e12512
commit cdca4a82ab
16 changed files with 805 additions and 4256 deletions

View File

@@ -4,15 +4,20 @@ const { app } = require("electron");
const config = require("../../config");
let userYtDlp;
let ffmpegPath;
const sourceYtDlp = path.join(process.resourcesPath, "yt-dlp.exe");
if (config.localMode === true) {
userYtDlp = path.join(__dirname, "../../ressources/yt-dlp.exe");
if (config.localMode) {
userYtDlp = path.join(__dirname, "../../ressources/yt-dlp.exe");
ffmpegPath = path.join(__dirname, "../../ressources/ffmpeg.exe");
} else {
userYtDlp = path.join(app.getPath("userData"), "yt-dlp.exe");
ffmpegPath = path.join(process.resourcesPath, "ffmpeg.exe");
userYtDlp = path.join(app.getPath("userData"), "yt-dlp.exe");
if (!fs.existsSync(userYtDlp)) fs.copyFileSync(sourceYtDlp, userYtDlp);
if (!fs.existsSync(userYtDlp)) {
fs.copyFileSync(sourceYtDlp, userYtDlp);
}
}
module.exports = { userYtDlp, sourceYtDlp };
module.exports = { userYtDlp, sourceYtDlp, ffmpegPath };

View File

@@ -9,7 +9,6 @@ const config = require("../../config");
const { isValidUrl, isSafePath } = require("../helpers/validation");
const { buildYtDlpArgs } = require("../helpers/buildArgs");
const { notifyDownloadFinished } = require("../helpers/notify");
const { userYtDlp } = require("../helpers/path");
const listeners = [];
@@ -23,43 +22,62 @@ router.post("/", (req, res) => {
outputFolder: req.body.savePath || path.join(process.env.USERPROFILE, "Downloads", "Freedom Loader"),
};
// Vérifications
if (!options.url || !isValidUrl(options.url)) return res.status(400).send("❌ URL invalide !");
if (!isSafePath(options.outputFolder)) return res.status(400).send("❌ Chemin de sauvegarde non autorisé.");
// Création dossier si inexistant
fs.mkdirSync(options.outputFolder, { recursive: true });
// Construire les arguments yt-dlp
const args = buildYtDlpArgs(options);
logger.info(args)
logger.info(`[yt-dlp args] ${args.join(" ")}`);
const child = execFile(userYtDlp, args);
// Gestion erreurs
child.on("error", err => {
logger.error(`Erreur yt-dlp : ${err.message}`);
res.status(500).send(`❌ Erreur yt-dlp : ${err.message}`);
});
// Téléchargement terminé
child.on("close", code => {
if (code === 0) {
notifyDownloadFinished(options.outputFolder);
// signal SSE fin de playlist
listeners.forEach(fn => fn("done"));
res.send("✅ Téléchargement terminé !");
} else res.status(500).send(`❌ yt-dlp a échoué avec le code : ${code}`);
} else {
res.status(500).send(`❌ yt-dlp a échoué avec le code : ${code}`);
listeners.forEach(fn => fn("done"));
}
});
if (config.debugMode == true) {
child.stdout.on("data", data => data.toString().split("\n").forEach(line => line.trim() && logger.info(`[yt-dlp stdout] ${line}`)));
child.stderr.on("data", data => data.toString().split("\n").forEach(line => line.trim() && logger.error(`[yt-dlp stderr] ${line}`)));
}
child.stdout.on("data", data => {
data.toString().split("\n").forEach(line => line.trim() && logger.info(`[yt-dlp stdout] ${line}`));
});
child.stderr.on("data", data => {
data.toString().split("\n").forEach(line => line.trim() && logger.error(`[yt-dlp stderr] ${line}`));
});
child.stdout.on("data", data => {
const lines = data.toString().split("\n");
lines.forEach(line => {
// reset progress si nouveau fichier
if (line.startsWith("[download] Destination:")) {
listeners.forEach(fn => fn("reset")); // tu peux envoyer un signal spécial
}
// envoyer le % classique
const match = line.match(/\[download\]\s+(\d+\.\d+)%/);
if (match) {
const percent = parseFloat(match[1]);
if (listeners.length > 0) {
listeners.forEach(fn => fn(percent));
}
listeners.forEach(fn => fn(percent));
}
});
});
@@ -78,10 +96,7 @@ router.get("/progress", (req, res) => {
'Connection': 'keep-alive',
});
const sendProgress = (percent) => {
res.write(`data: ${percent}\n\n`);
};
const sendProgress = percent => res.write(`data: ${percent}\n\n`);
listeners.push(sendProgress);
req.on('close', () => {
@@ -90,5 +105,4 @@ router.get("/progress", (req, res) => {
});
});
module.exports = router;
module.exports = router;

View File

@@ -28,7 +28,9 @@ router.post("/", (req, res) => {
"--cookies-from-browser",
`${getUserBrowser()}`,
"--extractor-args",
"youtube:player_client=default"
"youtube:player_client=default",
"--ignore-no-formats-error"
];
execFile(userYtDlp, args, { timeout: 30_000, maxBuffer: 10 * 1024 * 1024 }, (error, stdout, stderr) => {