fix(route/podcast): add fallback channel data (#20099)
This commit is contained in:
@@ -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,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user