mirror of
https://github.com/R0m1k3/podcastic.git
synced 2026-10-23 06:58:03 +02:00
feat: implement rssParserService to handle feed parsing, episode extraction, and database synchronization
This commit is contained in:
1 parent
6e9da01488
commit
0d9bffbc46
1 file changed
+18
-4
@@ -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
|
||||
|
||||
Reference in new issue
Block a user