diff --git a/supabase/functions/_shared/feed/podcast.ts b/supabase/functions/_shared/feed/podcast.ts index aff9cb2..083ca6b 100644 --- a/supabase/functions/_shared/feed/podcast.ts +++ b/supabase/functions/_shared/feed/podcast.ts @@ -68,8 +68,12 @@ export const getPodcastFeed = async ( if (feed.links.length > 0) { source.link = feed.links[0]; } - if (feed.image?.url) { - source.icon = feed.image?.url; + if ( + // deno-lint-ignore no-explicit-any + !source.icon && (feed.image?.url || (feed as any)["itunes:image"]?.href) + ) { + // deno-lint-ignore no-explicit-any + source.icon = feed.image?.url || (feed as any)["itunes:image"]?.href; source.icon = await uploadSourceIcon(supabaseClient, source); } @@ -85,13 +89,12 @@ export const getPodcastFeed = async ( break; } + const media = getMedia(entry); + /** - * If the entry does not contain a title, a link or a published date we skip it. + * If the entry does not contain a title, a published date or a media file we skip it. */ - if ( - !entry.title?.value || - (entry.links.length === 0 || !entry.links[0].href) || !entry.published - ) { + if (!entry.title?.value || !entry.published || !media) { continue; } @@ -103,7 +106,7 @@ export const getPodcastFeed = async ( let itemId = ""; if (entry.id != "") { itemId = generateItemId(source.id, entry.id); - } else if (entry.links.length > 0 && entry.links[0].href) { + } else if (entry.links && entry.links.length > 0 && entry.links[0].href) { itemId = generateItemId(source.id, entry.links[0].href); } else { continue; @@ -115,8 +118,10 @@ export const getPodcastFeed = async ( columnId: source.columnId, sourceId: source.id, title: entry.title.value, - link: entry.links[0].href, - media: getMedia(entry), + link: entry.links && entry.links.length > 0 && entry.links[0].href + ? entry.links[0].href + : media, + media: media, description: entry.description?.value ? unescape(entry.description.value) : undefined,