mirror of
https://github.com/MasterAcnolo/Freedom-Loader.git
synced 2026-07-29 18:25:47 +02:00
Feat: Implement Config File. Read by Front and Back. It aims to give possibility to disable some features quickly. Currenty: DiscordRPC, AutoCheckInfo, AutoUpdate, Custom TopBar, AddMetadata, Add Thumbail were put and implement. Other need to be implement. That's the begin of Settings Panel
This commit is contained in:
29
config.js
29
config.js
@@ -1,5 +1,20 @@
|
||||
const packageJson = require("./package.json");
|
||||
const { app } = require("electron");
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
|
||||
const featuresPath = path.join(__dirname, "./config/config.json");
|
||||
|
||||
let features = {};
|
||||
|
||||
function loadFeatures() {
|
||||
const raw = fs.readFileSync(featuresPath, "utf-8");
|
||||
features = JSON.parse(raw);
|
||||
console.log(features)
|
||||
return features;
|
||||
}
|
||||
|
||||
const configFeatures = loadFeatures();
|
||||
|
||||
module.exports = {
|
||||
version: packageJson.version,
|
||||
@@ -7,17 +22,5 @@ module.exports = {
|
||||
debugMode: true,
|
||||
localMode: !app.isPackaged,
|
||||
DiscordRPCID: "1410934537051181146",
|
||||
|
||||
// Variables Used to toggle main features
|
||||
autoUpdate: true,
|
||||
discordRPC: true,
|
||||
customTopBar: true, // (Will be active on next launch)
|
||||
autoDownloadPlaylist: true,
|
||||
logSystem: true, // Disable = Dangerous
|
||||
autoCheckInfo: true, // To Improve speed ? (NO)
|
||||
outputTitleCheck: true, // For Non latin characters (Russian)
|
||||
addThumbail: true, // The Pictures in the files (audio files)
|
||||
addMetadata: true, // Looks Explicit
|
||||
downloadSystem: true, // Why would you disable this ? I don't know but why not
|
||||
notifySystem: true // Notification when download
|
||||
configFeatures
|
||||
}
|
||||
13
config/config.json
Normal file
13
config/config.json
Normal file
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"autoUpdate": true,
|
||||
"discordRPC": true,
|
||||
"customTopBar": true,
|
||||
"autoDownloadPlaylist": true,
|
||||
"logSystem": true,
|
||||
"autoCheckInfo": true,
|
||||
"outputTitleCheck": true,
|
||||
"addThumbnail": true,
|
||||
"addMetadata": true,
|
||||
"downloadSystem": true,
|
||||
"notifySystem": true
|
||||
}
|
||||
15
main.js
15
main.js
@@ -3,8 +3,11 @@ const { app, BrowserWindow, ipcMain, dialog, Menu, shell } = require("electron")
|
||||
const path = require("path");
|
||||
const os = require("os");
|
||||
const fs = require("fs");
|
||||
|
||||
const { logger, logSessionStart, logSessionEnd, logDir } = require("./server/logger");
|
||||
const { AutoUpdater } = require("./server/update.js");
|
||||
const { configFeatures } = require("./config.js");
|
||||
const { startRPC } = require("./server/discordRPC");
|
||||
|
||||
let mainWindow;
|
||||
const logsFolderPath = logDir;
|
||||
@@ -77,7 +80,7 @@ async function createMainWindow() {
|
||||
height: 800,
|
||||
minWidth: 750,
|
||||
minHeight: 800,
|
||||
frame:false,
|
||||
frame: !configFeatures.customTopBar,
|
||||
webPreferences: {
|
||||
nodeIntegration: false,
|
||||
contextIsolation: true,
|
||||
@@ -163,11 +166,15 @@ app.whenReady().then(async () => {
|
||||
await expressServer.startServer();
|
||||
logger.info("Express Server Started");
|
||||
|
||||
const { startRPC } = require("./server/discordRPC");
|
||||
startRPC();
|
||||
ipcMain.handle("features", () => {
|
||||
return configFeatures;
|
||||
});
|
||||
|
||||
configFeatures.discordRPC ? startRPC() : "";
|
||||
|
||||
await createMainWindow();
|
||||
AutoUpdater(mainWindow);
|
||||
configFeatures.AutoUpdater ? AutoUpdater(mainWindow) : ""; // Auto Update
|
||||
|
||||
} catch (err) {
|
||||
logger.error("Window or Server error :", err);
|
||||
app.quit();
|
||||
|
||||
@@ -3,7 +3,8 @@ const { contextBridge, ipcRenderer } = require("electron");
|
||||
contextBridge.exposeInMainWorld("electronAPI", {
|
||||
getDefaultDownloadPath: () => ipcRenderer.invoke("get-default-download-path"),
|
||||
selectDownloadFolder: () => ipcRenderer.invoke("select-download-folder"),
|
||||
setProgress: (percent) => ipcRenderer.send("set-progress", percent)
|
||||
setProgress: (percent) => ipcRenderer.send("set-progress", percent),
|
||||
getFeatures: () => ipcRenderer.invoke("features")
|
||||
});
|
||||
|
||||
// Contrôles de fenêtre et outils custom pour la topbar
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="topbar">
|
||||
<div class="topbar" id="topbar">
|
||||
<div class="custom-controls">
|
||||
<button id="devtools-btn" title="Dev Tools">Tools</button>
|
||||
<button id="logs-btn" title="Logs">Logs</button>
|
||||
@@ -31,12 +31,12 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="theme-switcher">
|
||||
<div class="theme-switcher" id="theme-switcher">
|
||||
<label for="themeSelect">Thème :</label>
|
||||
<select id="themeSelect" aria-label="Choisir le thème"></select>
|
||||
</div>
|
||||
|
||||
<div class="container">
|
||||
<div class="container" id="container">
|
||||
|
||||
<header>
|
||||
<h1 id="title"> Freedom Loader </h1>
|
||||
|
||||
@@ -25,6 +25,10 @@ async function fetchVideoInfo(url) {
|
||||
return { error: "Network or JSON Issue" };
|
||||
}
|
||||
}
|
||||
async function init() {
|
||||
const configFeatures = await window.electronAPI.getFeatures();
|
||||
|
||||
if (!configFeatures.autoCheckInfo) return;
|
||||
|
||||
document.addEventListener("DOMContentLoaded", () => {
|
||||
const urlInput = document.getElementById("UrlInput");
|
||||
@@ -178,3 +182,7 @@ document.addEventListener("DOMContentLoaded", () => {
|
||||
});
|
||||
|
||||
})
|
||||
|
||||
};
|
||||
|
||||
init();
|
||||
@@ -21,4 +21,12 @@ function setupTopbarListeners() {
|
||||
});
|
||||
}
|
||||
|
||||
setupTopbarListeners();
|
||||
setupTopbarListeners(); // IF it put it the if check. It don't work. Why ?
|
||||
|
||||
const features = await window.electronAPI.getFeatures();
|
||||
|
||||
if(!features.customTopBar){
|
||||
document.getElementById("topbar").style.display = "none";
|
||||
document.getElementById("container").style.marginTop = "0";
|
||||
document.getElementById("theme-switcher").style.top = "30px";
|
||||
}
|
||||
@@ -2,6 +2,7 @@ const path = require("path");
|
||||
|
||||
const getUserBrowser = require("./getBrowser");
|
||||
const { ffmpegPath, denoPath} = require("./path");
|
||||
const { configFeatures } = require("../../config.js");
|
||||
|
||||
|
||||
function buildYtDlpArgs({ url, audioOnly, quality, outputFolder }) {
|
||||
@@ -10,8 +11,8 @@ function buildYtDlpArgs({ url, audioOnly, quality, outputFolder }) {
|
||||
"--cookies-from-browser", `${getUserBrowser()}`,
|
||||
"--no-continue",
|
||||
"--no-overwrites",
|
||||
"--embed-thumbnail",
|
||||
"--add-metadata",
|
||||
configFeatures.addThumbail ? "--embed-thumbnail" : null,
|
||||
configFeatures.addMetadata ? "--add-metadata" : null,
|
||||
"--concurrent-fragments", "8",
|
||||
"--retries", "10",
|
||||
"--fragment-retries", "10",
|
||||
@@ -37,7 +38,7 @@ function buildYtDlpArgs({ url, audioOnly, quality, outputFolder }) {
|
||||
args.push("-o", path.join(outputFolder, "%(title)s.%(ext)s"));
|
||||
args.push(url);
|
||||
|
||||
return args;
|
||||
return args.filter(Boolean);
|
||||
}
|
||||
|
||||
module.exports = { buildYtDlpArgs };
|
||||
|
||||
Reference in New Issue
Block a user