diff --git a/src/services/download.ts b/src/services/download.ts index 8494ac0..d954469 100644 --- a/src/services/download.ts +++ b/src/services/download.ts @@ -73,11 +73,17 @@ export class DownloadService { await this.rateLimiter.acquire(platform as Platform); // Build yt-dlp args + const template = formatProfile?.outputTemplate ?? undefined; const outputTemplate = this.fileOrganizer.buildOutputPath( platform, channelName, contentItem.title, - this.guessExtension(contentItem.contentType, formatProfile) + this.guessExtension(contentItem.contentType, formatProfile), + template, + { + contentType: contentItem.contentType, + id: contentItem.platformContentId, + } ); const args = this.buildYtDlpArgs( contentItem, diff --git a/src/services/file-organizer.ts b/src/services/file-organizer.ts index 40f282e..9abe641 100644 --- a/src/services/file-organizer.ts +++ b/src/services/file-organizer.ts @@ -78,7 +78,8 @@ export class FileOrganizer { channelName: string, title: string, ext: string, - template?: string + template?: string, + extra?: { contentType?: string; id?: string } ): string { const safeExt = ext.startsWith('.') ? ext.slice(1) : ext; const now = new Date(); @@ -91,6 +92,8 @@ export class FileOrganizer { date: now.toISOString().slice(0, 10), // YYYY-MM-DD year: String(now.getFullYear()), 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);