mirror of
https://github.com/MasterAcnolo/Freedom-Loader.git
synced 2026-09-28 04:21:15 +02:00
feat: Keep Playlist Order features. Add index before title if it's a playlist and we activate this feature.
This commit is contained in:
@@ -34,6 +34,7 @@ const FEATURE_WHITELIST = new Set([
|
|||||||
"addMetadata",
|
"addMetadata",
|
||||||
"verboseLogs",
|
"verboseLogs",
|
||||||
"autoDownloadPlaylist",
|
"autoDownloadPlaylist",
|
||||||
|
"keepPlaylistOrder",
|
||||||
"customCodec",
|
"customCodec",
|
||||||
"theme",
|
"theme",
|
||||||
"createPlaylistFolders",
|
"createPlaylistFolders",
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
"addMetadata": true,
|
"addMetadata": true,
|
||||||
"verboseLogs": false,
|
"verboseLogs": false,
|
||||||
"autoDownloadPlaylist": true,
|
"autoDownloadPlaylist": true,
|
||||||
|
"keepPlaylistOrder": false,
|
||||||
"createPlaylistFolders": true,
|
"createPlaylistFolders": true,
|
||||||
"customCodec": "h264",
|
"customCodec": "h264",
|
||||||
"logSystem": true,
|
"logSystem": true,
|
||||||
|
|||||||
@@ -112,6 +112,14 @@
|
|||||||
<small>Automatically fetch information for new downloads.</small>
|
<small>Automatically fetch information for new downloads.</small>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="setting-item">
|
||||||
|
<input data-key="keepPlaylistOrder" id="keepPlaylistOrder" type="checkbox">
|
||||||
|
<div class="setting-info">
|
||||||
|
<span class="setting-title">Keep Playlist Order</span>
|
||||||
|
<small>Add index before output file, to keep the order.</small>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ function validateCodec(codec){
|
|||||||
*
|
*
|
||||||
* @returns {string[]} Array of arguments ready to be passed to yt-dlp.
|
* @returns {string[]} Array of arguments ready to be passed to yt-dlp.
|
||||||
*/
|
*/
|
||||||
function buildYtDlpArgs({ url, audioOnly, quality, outputFolder }) {
|
function buildYtDlpArgs({url, audioOnly, quality, outputFolder, isPlaylist}) {
|
||||||
|
|
||||||
logger.info("--- CONFIGURATION ---");
|
logger.info("--- CONFIGURATION ---");
|
||||||
|
|
||||||
@@ -70,6 +70,7 @@ function buildYtDlpArgs({ url, audioOnly, quality, outputFolder }) {
|
|||||||
logger.info(`CONFIG discordRPC: ${configFeatures.discordRPC}`);
|
logger.info(`CONFIG discordRPC: ${configFeatures.discordRPC}`);
|
||||||
logger.info(`CONFIG customTopBar: ${configFeatures.customTopBar}`);
|
logger.info(`CONFIG customTopBar: ${configFeatures.customTopBar}`);
|
||||||
logger.info(`CONFIG autoCheckInfo: ${configFeatures.autoCheckInfo}`);
|
logger.info(`CONFIG autoCheckInfo: ${configFeatures.autoCheckInfo}`);
|
||||||
|
logger.info(`CONFIG keepPlaylistOrder: ${configFeatures.keepPlaylistOrder}`);
|
||||||
logger.info(`CONFIG addThumbnail: ${configFeatures.addThumbnail}`);
|
logger.info(`CONFIG addThumbnail: ${configFeatures.addThumbnail}`);
|
||||||
logger.info(`CONFIG addMetadata: ${configFeatures.addMetadata}`);
|
logger.info(`CONFIG addMetadata: ${configFeatures.addMetadata}`);
|
||||||
logger.info(`CONFIG verboseLogs: ${configFeatures.verboseLogs}`);
|
logger.info(`CONFIG verboseLogs: ${configFeatures.verboseLogs}`);
|
||||||
@@ -117,7 +118,19 @@ function buildYtDlpArgs({ url, audioOnly, quality, outputFolder }) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
args.push("-f", qualityMap[quality] || "best");
|
args.push("-f", qualityMap[quality] || "best");
|
||||||
args.push("-o", path.join(outputFolder, "%(title)s.%(ext)s"));
|
|
||||||
|
/**
|
||||||
|
* Default title output template
|
||||||
|
* @type {string}
|
||||||
|
*/
|
||||||
|
let outputTemplate = "%(title)s.%(ext)s";
|
||||||
|
|
||||||
|
// If it's a playlist, and we want to keep the playlist order. Add an index before the title.
|
||||||
|
if (isPlaylist && configFeatures.keepPlaylistOrder && configFeatures.autoDownloadPlaylist) {
|
||||||
|
outputTemplate = "%(playlist_index)02d - %(title)s.%(ext)s";
|
||||||
|
}
|
||||||
|
|
||||||
|
args.push("-o", path.join(outputFolder, outputTemplate));
|
||||||
args.push(url);
|
args.push(url);
|
||||||
|
|
||||||
return args.filter(Boolean);
|
return args.filter(Boolean);
|
||||||
|
|||||||
@@ -175,7 +175,12 @@ function fetchDownload(options, listeners, speedListeners, stageListeners, playl
|
|||||||
logger.info(`Playlist detected but createPlaylistFolders is disabled, using base folder`);
|
logger.info(`Playlist detected but createPlaylistFolders is disabled, using base folder`);
|
||||||
}
|
}
|
||||||
|
|
||||||
const args = buildYtDlpArgs({ ...options, outputFolder: safeOutputFolder });
|
const args = buildYtDlpArgs({
|
||||||
|
...options,
|
||||||
|
outputFolder: safeOutputFolder,
|
||||||
|
isPlaylist
|
||||||
|
});
|
||||||
|
|
||||||
logger.info(`[yt-dlp args] ${args.join(" ")}`);
|
logger.info(`[yt-dlp args] ${args.join(" ")}`);
|
||||||
|
|
||||||
const child = execFile(userYtDlp, args);
|
const child = execFile(userYtDlp, args);
|
||||||
|
|||||||
Reference in New Issue
Block a user