feat: Wire FormatProfile.outputTemplate into DownloadService with conte…

- "src/services/download.ts"
- "src/services/file-organizer.ts"

GSD-Task: S02/T03
This commit is contained in:
jlightner 2026-04-04 05:25:41 +00:00
parent 71175198bd
commit fb731377bd
2 changed files with 11 additions and 2 deletions

View file

@ -73,11 +73,17 @@ export class DownloadService {
await this.rateLimiter.acquire(platform as Platform); await this.rateLimiter.acquire(platform as Platform);
// Build yt-dlp args // Build yt-dlp args
const template = formatProfile?.outputTemplate ?? undefined;
const outputTemplate = this.fileOrganizer.buildOutputPath( const outputTemplate = this.fileOrganizer.buildOutputPath(
platform, platform,
channelName, channelName,
contentItem.title, contentItem.title,
this.guessExtension(contentItem.contentType, formatProfile) this.guessExtension(contentItem.contentType, formatProfile),
template,
{
contentType: contentItem.contentType,
id: contentItem.platformContentId,
}
); );
const args = this.buildYtDlpArgs( const args = this.buildYtDlpArgs(
contentItem, contentItem,

View file

@ -78,7 +78,8 @@ export class FileOrganizer {
channelName: string, channelName: string,
title: string, title: string,
ext: string, ext: string,
template?: string template?: string,
extra?: { contentType?: string; id?: string }
): string { ): string {
const safeExt = ext.startsWith('.') ? ext.slice(1) : ext; const safeExt = ext.startsWith('.') ? ext.slice(1) : ext;
const now = new Date(); const now = new Date();
@ -91,6 +92,8 @@ export class FileOrganizer {
date: now.toISOString().slice(0, 10), // YYYY-MM-DD date: now.toISOString().slice(0, 10), // YYYY-MM-DD
year: String(now.getFullYear()), year: String(now.getFullYear()),
month: String(now.getMonth() + 1).padStart(2, '0'), month: String(now.getMonth() + 1).padStart(2, '0'),
...(extra?.contentType != null ? { contentType: extra.contentType } : {}),
...(extra?.id != null ? { id: extra.id } : {}),
}; };
const resolved = this.resolveTemplate(template ?? DEFAULT_OUTPUT_TEMPLATE, vars); const resolved = this.resolveTemplate(template ?? DEFAULT_OUTPUT_TEMPLATE, vars);