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
43
44
45
46
47
48
49
50
51
import { fetch } from "https://esm.town/v/std/fetch";
export const internalStreamThesephistComRSS = (async () => {
const { DOMParser } = await import(
"https://deno.land/x/deno_dom/deno-dom-wasm.ts"
);
const { default: he } = await import("npm:he");
async function getRss() {
return fetch("https://stream.thesephist.com/?n=25")
.then(function (response) {
return response.text();
})
.then(function (html) {
var parser = new DOMParser();
let title = "Linus's stream";
let link = "https://api3.val.town/express/@coofdy.streamThesaphistRSS";
let base = "https://stream.thesephist.com";
var rss = [
`<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title>${title}</title>
<description>${title}</description>
<link>${link}</link>
<ttl>240</ttl>`,
];
var doc = parser.parseFromString(html, "text/html");
var posts = doc.querySelectorAll(".update");
for (var i = 0, len = posts.length; i < len; i++) {
let content = posts[i].querySelector(".update-s").innerHTML;
let metadata = posts[i].querySelector(".update-t");
let timestamp = metadata.getAttribute("data-timestamp");
let date = new Date(timestamp * 1000).toUTCString();
rss.push(`<item>
<description>${he.encode(content)}</description>
<link>${
base + metadata.querySelector(".clockstamp").getAttribute("href")
}</link>
<guid isPermaLink="false">${timestamp}</guid>
<pubDate>${date}</pubDate>
</item>`);
}
rss.push(`</channel></rss>`);
return rss.join("");
})
.catch(function (err) {
return "Failed to fetch page: " + err;
});
}
return await getRss();
})();