From 4d2241769ec9a7d77926f99cd1986412da4eb0eb Mon Sep 17 00:00:00 2001 From: Toni Barth Date: Wed, 18 Dec 2024 19:15:09 +0100 Subject: [PATCH] also check for mrss item enclosures when extracting items --- server/utils/podcastUtils.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/server/utils/podcastUtils.js b/server/utils/podcastUtils.js index 627e24b290..0d3625932b 100644 --- a/server/utils/podcastUtils.js +++ b/server/utils/podcastUtils.js @@ -75,15 +75,19 @@ function extractPodcastMetadata(channel) { function extractEpisodeData(item) { // Episode must have url - if (!item.enclosure?.[0]?.['$']?.url) { + let enclosure + + if (item.enclosure?.[0]?.['$']?.url) { + enclosure = item.enclosure[0]['$'] + } else if(item['media:content']?.find(c => c?.['$']?.url && (c?.['$']?.type ?? "").startsWith("audio"))) { + enclosure = item['media:content'].find(c => (c['$']?.type ?? "").startsWith("audio"))['$'] + } else { Logger.error(`[podcastUtils] Invalid podcast episode data`) return null } const episode = { - enclosure: { - ...item.enclosure[0]['$'] - } + enclosure: enclosure, } episode.enclosure.url = episode.enclosure.url.trim()