From 7738a78b97daabf9f8d8ba3c5abd792ea75baa87 Mon Sep 17 00:00:00 2001 From: Tony Date: Fri, 19 Sep 2025 05:15:04 +0800 Subject: [PATCH] fix(route/podcast): add fallback channel data (#20099) --- lib/routes/apple/podcast.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/routes/apple/podcast.ts b/lib/routes/apple/podcast.ts index 9ca05036c..07853678a 100644 --- a/lib/routes/apple/podcast.ts +++ b/lib/routes/apple/podcast.ts @@ -92,15 +92,15 @@ async function handler(ctx) { }; }); - const channel = episodeReponse.data.find((d) => d.type === 'podcast-episodes').relationships.channel.data.find((d) => d.type === 'podcast-channels').attributes; + const channel = episodeReponse.data.find((d) => d.type === 'podcast-episodes').relationships.channel.data.find((d) => d.type === 'podcast-channels')?.attributes; return { - title: channel.name, - link: channel.url, + title: channel?.name ?? header.title, + link: channel?.url ?? header.contextAction.podcastOffer.storeUrl, itunes_author: header.contextAction.podcastOffer.author, item: episodes, - description: (header.description || channel.description.standard).replaceAll('\n', ' '), - image: (channel.logoArtwork || channel.subscriptionArtwork).url.replace(/\{w\}x\{h\}(?:\{c\}|bb)\.\{f\}/, '3000x3000bb.webp'), + description: (header.description || channel?.description.standard)?.replaceAll('\n', ' '), + image: ((channel?.logoArtwork || channel?.subscriptionArtwork)?.url || header.contextAction.podcastOffer.artwork.template).replace(/\{w\}x\{h\}(?:\{c\}|bb)\.\{f\}/, '3000x3000bb.webp'), itunes_category: header.metadata.find((d) => Object.hasOwn(d, 'category')).category?.title || header.metadata.find((d) => Object.hasOwn(d, 'category')).category, }; }