mirror of
https://github.com/MasterAcnolo/Freedom-Loader.git
synced 2026-07-29 18:25:47 +02:00
Using MVC Model + AutoDeteck Package + Fix Download/Info
This commit is contained in:
@@ -1,8 +1,11 @@
|
||||
const path = require("path");
|
||||
|
||||
const getUserBrowser = require("./getBrowser")
|
||||
const getUserBrowser = require("./getBrowser");
|
||||
const { ffmpegPath, denoPath} = require("./path");
|
||||
|
||||
|
||||
function buildYtDlpArgs({ url, audioOnly, quality, outputFolder }) {
|
||||
|
||||
const args = [
|
||||
"--cookies-from-browser", `${getUserBrowser()}`,
|
||||
"--no-continue",
|
||||
@@ -12,9 +15,9 @@ function buildYtDlpArgs({ url, audioOnly, quality, outputFolder }) {
|
||||
"--concurrent-fragments", "8",
|
||||
"--retries", "10",
|
||||
"--fragment-retries", "10",
|
||||
"--ffmpeg-location", path.join(process.resourcesPath, "ffmpeg.exe"),
|
||||
"--ffmpeg-location", ffmpegPath,
|
||||
"--extractor-args","youtube:player_client=default",
|
||||
"--js-runtimes", `deno:${path.join(process.resourcesPath, "deno.exe")}`
|
||||
"--js-runtimes", `deno:${denoPath}`
|
||||
];
|
||||
|
||||
if (audioOnly) args.push("-f", "bestaudio", "--extract-audio", "--audio-format", "mp3");
|
||||
|
||||
39
server/helpers/parseInfo.js
Normal file
39
server/helpers/parseInfo.js
Normal file
@@ -0,0 +1,39 @@
|
||||
const { logger } = require("../logger");
|
||||
|
||||
function parseVideo(data) {
|
||||
|
||||
// logger.info(`Avant parse: ${JSON.stringify(data, null, 2)}`);
|
||||
|
||||
return {
|
||||
type: "video",
|
||||
// id: data.id,
|
||||
// title: data.title,
|
||||
// url: data.webpage_url,
|
||||
// duration: data.duration,
|
||||
// thumbnail: data.thumbnail,
|
||||
// uploader: data.uploader
|
||||
...data
|
||||
};
|
||||
}
|
||||
|
||||
function parsePlaylist(data) {
|
||||
|
||||
// logger.info(`Avant parse: ${JSON.stringify(data, null, 2)}`);
|
||||
|
||||
return {
|
||||
type: "playlist",
|
||||
title: data.title || data.id,
|
||||
channel: data.uploader,
|
||||
count: data.entries.length,
|
||||
videos: (data.entries || []).map(v => ({
|
||||
id: v.id,
|
||||
title: v.title,
|
||||
url: v.webpage_url,
|
||||
duration: v.duration,
|
||||
thumbnail: v.thumbnail,
|
||||
uploader: v.uploader
|
||||
}))
|
||||
};
|
||||
}
|
||||
|
||||
module.exports = { parseVideo, parsePlaylist };
|
||||
@@ -5,19 +5,22 @@ const config = require("../../config");
|
||||
|
||||
let userYtDlp;
|
||||
let ffmpegPath;
|
||||
let denoPath;
|
||||
|
||||
const sourceYtDlp = path.join(process.resourcesPath, "yt-dlp.exe");
|
||||
|
||||
if (config.localMode) {
|
||||
userYtDlp = path.join(__dirname, "../../ressources/yt-dlp.exe");
|
||||
ffmpegPath = path.join(__dirname, "../../ressources/ffmpeg.exe");
|
||||
ffmpegPath = path.join(__dirname, "../../ressources"); // <- contient ffmpeg.exe et ffprobe.exe
|
||||
denoPath = path.join(__dirname, "../../ressources/deno.exe");
|
||||
} else {
|
||||
userYtDlp = path.join(app.getPath("userData"), "yt-dlp.exe");
|
||||
ffmpegPath = path.join(process.resourcesPath, "ffmpeg.exe");
|
||||
ffmpegPath = path.join(process.resourcesPath, "ressources"); // <- ici aussi
|
||||
denoPath = path.join(process.resourcesPath, "deno.exe");
|
||||
|
||||
if (!fs.existsSync(userYtDlp)) {
|
||||
fs.copyFileSync(sourceYtDlp, userYtDlp);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = { userYtDlp, sourceYtDlp, ffmpegPath };
|
||||
module.exports = { userYtDlp, ffmpegPath, denoPath };
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
const path = require("path");
|
||||
|
||||
function isValidUrl(url) {
|
||||
try {
|
||||
new URL(url);
|
||||
return true;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
function isValidUrl(url) {
|
||||
try {
|
||||
new URL(url);
|
||||
return true;
|
||||
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function isSafePath(folder) {
|
||||
|
||||
Reference in New Issue
Block a user