mirror of
https://github.com/MasterAcnolo/Freedom-Loader.git
synced 2026-09-27 20:11: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:
committed by
MasterAcnolo
parent
bbb0b58d17
commit
e09f1a8913
@@ -62,7 +62,7 @@ function validateCodec(codec){
|
||||
*
|
||||
* @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 ---");
|
||||
|
||||
@@ -70,6 +70,7 @@ function buildYtDlpArgs({ url, audioOnly, quality, outputFolder }) {
|
||||
logger.info(`CONFIG discordRPC: ${configFeatures.discordRPC}`);
|
||||
logger.info(`CONFIG customTopBar: ${configFeatures.customTopBar}`);
|
||||
logger.info(`CONFIG autoCheckInfo: ${configFeatures.autoCheckInfo}`);
|
||||
logger.info(`CONFIG keepPlaylistOrder: ${configFeatures.keepPlaylistOrder}`);
|
||||
logger.info(`CONFIG addThumbnail: ${configFeatures.addThumbnail}`);
|
||||
logger.info(`CONFIG addMetadata: ${configFeatures.addMetadata}`);
|
||||
logger.info(`CONFIG verboseLogs: ${configFeatures.verboseLogs}`);
|
||||
@@ -117,7 +118,19 @@ function buildYtDlpArgs({ url, audioOnly, quality, outputFolder }) {
|
||||
};
|
||||
|
||||
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);
|
||||
|
||||
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`);
|
||||
}
|
||||
|
||||
const args = buildYtDlpArgs({ ...options, outputFolder: safeOutputFolder });
|
||||
const args = buildYtDlpArgs({
|
||||
...options,
|
||||
outputFolder: safeOutputFolder,
|
||||
isPlaylist
|
||||
});
|
||||
|
||||
logger.info(`[yt-dlp args] ${args.join(" ")}`);
|
||||
|
||||
const child = execFile(userYtDlp, args);
|
||||
|
||||
Reference in New Issue
Block a user