UNPKG

rsshub

Version:
54 lines (53 loc) 1.83 kB
import { t as rofetch } from "./ofetch-U0CdpE2g.mjs"; import { t as parseDate } from "./parse-date-3kcy2Eau.mjs"; import { t as cache_default } from "./cache-C1Y-9qDV.mjs"; import { load } from "cheerio"; //#region lib/routes/maldita/updates.ts const route = { path: "/updates/:category?", categories: ["new-media"], example: "/maldita/updates/desinfo", parameters: { category: "Category to fetch" }, features: { requireConfig: false, requirePuppeteer: false, antiCrawler: false, supportBT: false, supportPodcast: false, supportScihub: false }, radar: [{ source: ["maldita.es/:category/"], target: "/updates/:category" }], name: "Latest Updates", maintainers: ["canonnizq"], description: "Categories: all | desinfo | prebunking | investigaciones | control-del-poder | policy", handler: async (ctx) => { const { category = "all" } = ctx.req.param(); const url = `https://maldita.es/${category === "all" ? "" : `${category}/`}`; const response = await rofetch(url); const $ = load(response); const name = $("h1").text() || "All updates"; const links = $(category === "all" ? "a.ac-link" : "#content a[href*=\"maldita.es\"]:has(div)").toArray().map((item) => $(item).attr("href")); const items = await Promise.all(links.map((link) => cache_default.tryGet(link, async () => { const response = await rofetch(link); const $ = load(response); return { title: $("h1").text(), link, category: $("#article-metadata .flex a").toArray().map((x) => $(x).text()), pubDate: parseDate($("time").attr("datetime")), itunes_item_image: $("#featuredImage img").attr("src"), content: { html: $("#keys").html() + $("#article-content").html() } }; }))); return { title: `Maldita.es - ${name}`, link: url, item: items }; } }; //#endregion export { route };