fix(route/podcast): add fallback channel data (#20099)

This commit is contained in:
Tony
2025-09-19 05:15:04 +08:00
committed by GitHub
parent fd4d1c4030
commit 7738a78b97
+5 -5
View File
@@ -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,
};
}