1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import { makeRssXml } from "https://esm.town/v/pettan/makeRssXml";
import { escapeXml } from "https://esm.town/v/pettan/escapeXml";
import { previousDjs } from "https://esm.town/v/pettan/previousDjs";
export const generateRAdioDjRss = async (
_req: express.Request,
res: express.Response
) => {
const rssItems = previousDjs.map((dj) => {
const djImgSrc = `https://r-a-d.io/api/dj-image/${encodeURIComponent(
dj.djimage
)}`;
const djMessage =
dj.djtext === "" || dj.djtext === "x"
? ""
: `${dj.djname} says: ${dj.djtext}`;
const threadMessage =
dj.thread === "" || dj.thread === "none"
? ""
: `Thread link: [${escapeXml(dj.thread)}]`;
return {
guid: dj.guid,
isPermaLink: false,
title: dj.title,
description: `
<img src="${djImgSrc}"/>
${djMessage}
${threadMessage}
`,
link: dj.link,
pubDate: dj.startedTime,
};
});
const rssBody = makeRssXml(rssItems, {
title: "R/a/dio DJ changes",
link: "https://r-a-d.io/",
description:
"Informing you of when the DJ changes on r/a/dio with only a 15 minute delay!",
rssLink: "https://api.val.town/v1/express/pettan.generateRAdioDjRss",
});
return res.type("application/rss+xml").send(rssBody);
};