From fb731377bd2001d6c2bc1369b71a370c9440db4d Mon Sep 17 00:00:00 2001 From: jlightner Date: Sat, 4 Apr 2026 05:25:41 +0000 Subject: [PATCH] =?UTF-8?q?feat:=20Wire=20FormatProfile.outputTemplate=20i?= =?UTF-8?q?nto=20DownloadService=20with=20conte=E2=80=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - "src/services/download.ts" - "src/services/file-organizer.ts" GSD-Task: S02/T03 --- src/services/download.ts | 8 +++++++- src/services/file-organizer.ts | 5 ++++- 2 files changed, 11 insertions(+), 2 deletions(-) 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);