Skip to content

Commit 7738a78

Browse files
authored
fix(route/podcast): add fallback channel data (DIYgod#20099)
1 parent fd4d1c4 commit 7738a78

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

lib/routes/apple/podcast.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,15 +92,15 @@ async function handler(ctx) {
9292
};
9393
});
9494

95-
const channel = episodeReponse.data.find((d) => d.type === 'podcast-episodes').relationships.channel.data.find((d) => d.type === 'podcast-channels').attributes;
95+
const channel = episodeReponse.data.find((d) => d.type === 'podcast-episodes').relationships.channel.data.find((d) => d.type === 'podcast-channels')?.attributes;
9696

9797
return {
98-
title: channel.name,
99-
link: channel.url,
98+
title: channel?.name ?? header.title,
99+
link: channel?.url ?? header.contextAction.podcastOffer.storeUrl,
100100
itunes_author: header.contextAction.podcastOffer.author,
101101
item: episodes,
102-
description: (header.description || channel.description.standard).replaceAll('\n', ' '),
103-
image: (channel.logoArtwork || channel.subscriptionArtwork).url.replace(/\{w\}x\{h\}(?:\{c\}|bb)\.\{f\}/, '3000x3000bb.webp'),
102+
description: (header.description || channel?.description.standard)?.replaceAll('\n', ' '),
103+
image: ((channel?.logoArtwork || channel?.subscriptionArtwork)?.url || header.contextAction.podcastOffer.artwork.template).replace(/\{w\}x\{h\}(?:\{c\}|bb)\.\{f\}/, '3000x3000bb.webp'),
104104
itunes_category: header.metadata.find((d) => Object.hasOwn(d, 'category')).category?.title || header.metadata.find((d) => Object.hasOwn(d, 'category')).category,
105105
};
106106
}

0 commit comments

Comments
 (0)