2025-11-26 03:34:32 -08:00

74 lines
2.1 KiB
Plaintext

<%#
index.ejs — RSS Feed Generator (RSS 2.0)
Expects: data.vods = [{ id, title, notes, thumbnail, streamDate, magnetLink }]
When in doubt, copy https://nyaa.si/?page=rss
%>
<%
response.header("Content-Type", "application/rss+xml");
let rss = `<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:torrent="http://xmlns.ezrss.it/0.1/">
<channel>
<title>Futureporn.net VODs</title>
<link>https://futureporn.net</link>
<description>Dedication to the preservation of lewdtuber history</description>
<lastBuildDate>${new Date().toUTCString()}</lastBuildDate>
<docs>https://validator.w3.org/feed/docs/rss2.html</docs>
<generator>pocketpages</generator>
<language>en</language>
<image>
<title>Futureporn.net</title>
<url>https://futureporn.net/images/futureporn-icon.png</url>
<link>https://futureporn.net</link>
</image>`;
for (const vod of data.vods) {
const vodId = vod.get('id');
const title =
(vod?.get('expand')?.vtubers?.map(v => v.get('displayName')).join(', '))
|| vod.get('streamDate');
const vodUrl = `${env('ORIGIN')}/vods/${vodId}`;
const pubDate = new Date(vod.get('streamDate')).toUTCString();
const notes = vod.get('notes');
const thumbnail = vod.get('thumbnail');
const magnetLink = vod.get('magnetLink');
// @TODO the <link> must contain a .torrent, NOT a magnetLink.
rss += `
<item>
<title><![CDATA[${title}]]></title>
<comments>${vodUrl}</comments>
<link>${vodUrl}</link>
<guid isPermaLink="true">${vodUrl}</guid>
<pubDate>${pubDate}</pubDate>`;
// Description
if (notes) {
rss += `
<description><![CDATA[<a href="${vodUrl}">${vodUrl}</a> ${notes}]]></description>`;
}
// Thumbnail (custom tag — allowed)
if (thumbnail) {
rss += `
<image_link>${env('ORIGIN')}/api/files/vods/${vodId}/${thumbnail}</image_link>`;
}
rss += `
</item>`;
}
rss += `
</channel>
</rss>`;
response.html(200, rss);
%>