From 76e7611d8d140409eb77ffb659cf18c9a1677df4 Mon Sep 17 00:00:00 2001 From: jlightner Date: Sat, 4 Apr 2026 10:39:13 +0000 Subject: [PATCH] =?UTF-8?q?fix:=20Fixed=20cross-platform=20enrichment=20bu?= =?UTF-8?q?g=20(hardcoded=20YouTube=20URLs=20for=20So=E2=80=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - "src/services/scheduler.ts" - "src/services/missing-file-scanner.ts" GSD-Task: S08/T02 --- src/services/missing-file-scanner.ts | 14 ++++++++++---- src/services/scheduler.ts | 6 ++++-- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/services/missing-file-scanner.ts b/src/services/missing-file-scanner.ts index 296f1f3..a265191 100644 --- a/src/services/missing-file-scanner.ts +++ b/src/services/missing-file-scanner.ts @@ -116,10 +116,16 @@ export class MissingFileScanner { .from(systemConfig) .where(eq(systemConfig.key, SCAN_LAST_RESULT_KEY)); - return { - lastRun: rows[0].value, - result: resultRows.length > 0 ? JSON.parse(resultRows[0].value) : { checked: 0, missing: 0, duration: 0 }, - }; + let result: ScanResult = { checked: 0, missing: 0, duration: 0 }; + if (resultRows.length > 0) { + try { + result = JSON.parse(resultRows[0].value) as ScanResult; + } catch { + // Corrupt stored result — return default + } + } + + return { lastRun: rows[0].value, result }; } // ── Private ── diff --git a/src/services/scheduler.ts b/src/services/scheduler.ts index 6b706c0..a8868af 100644 --- a/src/services/scheduler.ts +++ b/src/services/scheduler.ts @@ -480,9 +480,11 @@ export class SchedulerService { } try { - const videoUrl = `https://www.youtube.com/watch?v=${item.platformContentId}`; + // Use the item's original URL (platform-agnostic) instead of + // hardcoding YouTube — SoundCloud / generic items have their own URLs. + const contentUrl = item.url || `https://www.youtube.com/watch?v=${item.platformContentId}`; const enrichResult = await execYtDlp( - ['--dump-json', '--no-playlist', videoUrl], + ['--dump-json', '--no-playlist', contentUrl], { timeout: 15_000 } );