From 63a99c07cf66b4ad8fe5737ab26c821413abe77d Mon Sep 17 00:00:00 2001 From: Izumiko Date: Fri, 1 Nov 2024 14:29:35 +0800 Subject: [PATCH] Add placeholder for rss if no rss item --- server/rss.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/server/rss.js b/server/rss.js index 4d775f5..bbd971a 100644 --- a/server/rss.js +++ b/server/rss.js @@ -108,6 +108,27 @@ const route = async (req, res) => { break; } } + // if items is empty, add placeholder to keep rss valid + if (!items.length) items.push({ + title: ["Placeholder"], + pubDate: [new Date().toISOString()], + enclosure: [ + { + $: { + url: "https://placeholder.com", + type: "application/x-bittorrent", + length: 0, + }, + }, + ], + link: ["https://placeholder.com"], + guid: [ + { + $: { isPermaLink: true }, + _: "https://placeholder.com", + }, + ], + }); result.rss.channel[0].item = items; res.set("Content-Type", "text/xml"); res.send(builder.buildObject(result));