mirror of
https://github.com/MasterAcnolo/Freedom-Loader.git
synced 2026-07-29 18:25:47 +02:00
refactor: add full documentation and fix theme loading robustness
- Add JSDoc comments across frontend and backend modules - Improve code readability and maintainability with consistent documentation style - Document Electron IPC handlers, UI utilities, and theme system - Add missing function/class documentation in theme loader and app services - Minor structural improvements and cleanup across Electron main process modules - Minor fixes on variable names
This commit is contained in:
@@ -3,8 +3,30 @@ const { userYtDlp, denoPath } = require("../helpers/path.helpers");
|
||||
const getUserBrowser = require("../helpers/getBrowser.helpers");
|
||||
const { logger } = require("../logger");
|
||||
|
||||
/**
|
||||
* Retrieves metadata for a video or playlist using yt-dlp.
|
||||
*
|
||||
* The command executes yt-dlp in JSON mode and returns the
|
||||
* parsed response object without downloading any media.
|
||||
*
|
||||
* Features:
|
||||
* - Supports videos and playlists
|
||||
* - Imports browser cookies when available
|
||||
* - Uses Deno for JavaScript extraction
|
||||
* - Applies a 30-second timeout
|
||||
* - Limits response size to 10 MB
|
||||
*
|
||||
* @param {string} url - Video or playlist URL to inspect.
|
||||
* @returns {Promise<Object>} Resolves with the metadata returned by yt-dlp.
|
||||
*
|
||||
*/
|
||||
function fetchInfo(url) {
|
||||
const args = [
|
||||
|
||||
/**
|
||||
* Base yt-dlp arguments used to retrieve metadata
|
||||
* without downloading media files.
|
||||
*/
|
||||
const metadataArgs = [
|
||||
"--js-runtimes", `deno:${denoPath}`,
|
||||
"--dump-single-json",
|
||||
"--ignore-errors",
|
||||
@@ -16,9 +38,9 @@ function fetchInfo(url) {
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
|
||||
execFile(userYtDlp,[...args, url],
|
||||
execFile(userYtDlp,[...metadataArgs , url],
|
||||
{ timeout: 30_000, // 30s, if more timeout
|
||||
maxBuffer: 10 * 1024 * 1024 }, // 10MO max response (Default: 200ko)
|
||||
maxBuffer: 10 * 1024 * 1024 }, // Maximum response size: 10 MB (Node.js default is much smaller)
|
||||
|
||||
(error, stdout, stderr) => {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user