Feed endpoint returns rss+xml, not xml

This commit is contained in:
olaven 2023-03-11 19:51:30 +01:00
parent b09eb877d6
commit 72aad6c8f8
1 changed files with 10 additions and 3 deletions

View File

@ -24,6 +24,7 @@ function toItemTag(episode: Episode) {
async function buildFeed(seriesId: string) { async function buildFeed(seriesId: string) {
const serie = await nrkRadio.getSerieData(seriesId) const serie = await nrkRadio.getSerieData(seriesId)
const imageUrl = serie.squareImage.at(-1)?.url; const imageUrl = serie.squareImage.at(-1)?.url;
const linkValue = `https://radio.nrk.no/podkast/${serie.id}`;
// Quickly adapted from https://raw.githubusercontent.com/olaven/paperpod/1cde9abd3174b26e126aa74fc5a3b63fd078c0fd/packages/converter/src/rss.ts // Quickly adapted from https://raw.githubusercontent.com/olaven/paperpod/1cde9abd3174b26e126aa74fc5a3b63fd078c0fd/packages/converter/src/rss.ts
return serialize( return serialize(
@ -31,16 +32,21 @@ async function buildFeed(seriesId: string) {
["version", "1.0"], ["version", "1.0"],
["encoding", "UTF-8"], ["encoding", "UTF-8"],
]), ]),
tag("atom:link", "", [
["href", linkValue],
["rel", "self"],
["type", "application/rss+xml"]
]),
tag( tag(
"rss", "rss",
[ [
tag("channel", [ tag("channel", [
tag("title", serie.titles.title), tag("title", serie.titles.title),
tag("link", `https://radio.nrk.no/podkast/${serie.id}`), tag("link", linkValue),
tag("itunes:author", "NRK"), tag("itunes:author", "NRK"),
tag( tag(
"description", "description",
serie.titles.subtitle || "" serie.titles.subtitle || ""
), ),
tag("ttl", "60"), //60 minutes tag("ttl", "60"), //60 minutes
...(imageUrl ? [ ...(imageUrl ? [
@ -50,6 +56,7 @@ async function buildFeed(seriesId: string) {
tag("image", [ tag("image", [
tag("url", imageUrl), tag("url", imageUrl),
tag("title", serie.titles.title), tag("title", serie.titles.title),
tag("link", linkValue),
]) ])
] : []), ] : []),
...serie.episodes.map(toItemTag), ...serie.episodes.map(toItemTag),
@ -70,7 +77,7 @@ export const handler = async (req: Request, _ctx: HandlerContext): Promise<Respo
return new Response(feedContent, { return new Response(feedContent, {
headers: { headers: {
"Content-Type": "application/xml" "Content-Type": "application/rss+xml"
} }
}); });
}; };