From 0d9bffbc4603297b9c6a27e740146f93fff36d65 Mon Sep 17 00:00:00 2001 From: R0m1k3 Date: Thu, 16 Apr 2026 14:15:18 +0200 Subject: [PATCH] feat: implement rssParserService to handle feed parsing, episode extraction, and database synchronization --- backend/src/services/rssParserService.ts | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/backend/src/services/rssParserService.ts b/backend/src/services/rssParserService.ts index 21302d4..5c75a78 100644 --- a/backend/src/services/rssParserService.ts +++ b/backend/src/services/rssParserService.ts @@ -45,11 +45,25 @@ export const rssParserService = { throw new Error('Invalid RSS feed - missing title'); } + // Robust image extraction + let imageUrl = feed.image?.url; + if (!imageUrl && feed.itunes?.image) { + imageUrl = typeof feed.itunes.image === 'string' ? feed.itunes.image : feed.itunes.image.href; + } + + // Robust author extraction + const author = feed.author || feed.creator || feed.itunes?.author || (feed as any).managingEditor || ''; + + // Robust description extraction + const description = feed.description || feed.itunes?.summary || feed.itunes?.subtitle || (feed as any).content || ''; + + console.log(`[RSS Parser] Meta Extracted for "${feed.title}": Author: ${author}, Image: ${!!imageUrl}`); + return { title: feed.title, - description: feed.description || feed.itunes?.summary || feed.itunes?.subtitle || '', - author: feed.author || feed.creator || feed.itunes?.author || '', - imageUrl: feed.image?.url || feed.itunes?.image, + description: description, + author: author, + imageUrl: imageUrl, language: feed.language?.split('-')[0].toLowerCase() || '', episodes: feed.items || [], }; @@ -123,7 +137,7 @@ export const rssParserService = { extractImageUrl: (item: any, podcastImage?: string): string | undefined => { // Try iTunes image first if (item.itunes?.image) { - return item.itunes.image; + return typeof item.itunes.image === 'string' ? item.itunes.image : item.itunes.image.href; } // Try media content