rsshub
Version:
Make RSS Great Again!
64 lines (62 loc) • 2.41 kB
JavaScript
import { n as init_esm_shims, t as __dirname } from "./esm-shims-CzJ_djXG.mjs";
import "./config-C37vj7VH.mjs";
import "./dist-BInvbO1W.mjs";
import "./logger-Czu8UMNd.mjs";
import { t as ofetch_default } from "./ofetch-BIyrKU3Y.mjs";
import { t as parseDate } from "./parse-date-BrP7mxXf.mjs";
import { t as art } from "./render-BQo6B4tL.mjs";
import { t as timezone } from "./timezone-D8cuwzTY.mjs";
import path from "node:path";
import { load } from "cheerio";
//#region lib/routes/warthunder/news.ts
init_esm_shims();
const renderDescription = (desc) => art(path.join(__dirname, "templates/description-c88c7c54.art"), desc);
const route = {
path: "/news",
categories: ["game"],
example: "/warthunder/news",
parameters: {},
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false
},
radar: [{ source: ["warthunder.com/en/news", "warthunder.com/"] }],
name: "News",
maintainers: ["axojhf"],
handler,
url: "warthunder.com/en/news",
description: `News data from [https://warthunder.com/en/news/](https://warthunder.com/en/news/)
The \`pubDate\` provided under UTC time zone, so please ignore the specific time!!!`
};
async function handler() {
const $ = load(await ofetch_default("https://warthunder.com/en/news/"));
return {
title: "War Thunder News",
link: "https://warthunder.com/en/news/",
item: $("div.showcase__item.widget").toArray().map((item) => {
item = $(item);
let pubDate = parseDate(item.find("div.widget__content > ul > li.widget-meta__item.widget-meta__item--right").text(), "D MMMM YYYY", "en");
pubDate = timezone(pubDate, 0);
const category = [];
if (item.find("div.widget__pin").length !== 0) category.push("pinned");
if (item.find("a.widget__decal").length !== 0) category.push("decal");
if (item.find("div.widget__badge").length !== 0) category.push(item.find("div.widget__badge").text());
return {
link: `https://warthunder.com${item.find("a.widget__link").attr("href")}`,
title: item.find("div.widget__content > div.widget__title").text(),
pubDate,
description: renderDescription({
description: item.find("div.widget__content > div.widget__comment").text(),
imglink: item.find("div.widget__poster > img.widget__poster-media").attr("data-src")
}),
category
};
})
};
}
//#endregion
export { route };