rsshub
Version:
Make RSS Great Again!
49 lines (48 loc) • 1.68 kB
JavaScript
import { t as config } from "./config-CCmw1BNE.mjs";
import { t as processItems } from "./utils-_Su4dma5.mjs";
import Parser from "rss-parser";
//#region lib/routes/dw/rss.ts
const route = {
path: "/rss/:channel?",
categories: ["traditional-media"],
example: "/dw/rss/rss-en-all",
parameters: { category: "RSS Feed Channel, see below, `rss-en-all` by default" },
features: {
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false,
requireConfig: false
},
name: "RSS",
maintainers: ["quiniapiezoelectricity"],
handler,
description: `For a full list of RSS Feed Channels in English, please refer to [DW RSS Feeds](https://corporate.dw.com/en/rss-feeds/a-68693346).
RSS Feed Channels in other languages are also available, for example: \`rss-chi-all\` renders the RSS feed in Chinese and \`rss-de-all\` for the RSS Feed in German`
};
async function handler(ctx) {
const category = ctx.req.param("channel") ?? "rss-en-all";
const feed = await new Parser({
customFields: { item: ["dwsyn:contentID"] },
headers: { "User-Agent": config.ua }
}).parseURL(`https://rss.dw.com/rdf/${category}`);
const items = await processItems(feed.items.map((item) => {
item.id = item["dwsyn:contentID"];
item.pubDate = item.isoDate;
item.description = item.content;
const link = new URL(item.link);
link.search = "";
item.link = link.href;
item.type = link.pathname.slice(link.pathname.lastIndexOf("/") + 1).startsWith("live-") ? "liveblog" : "article";
return item;
}));
return {
title: feed.title,
link: feed.link,
description: feed.description,
item: items
};
}
//#endregion
export { route };