UNPKG

rsshub

Version:
56 lines (54 loc) 1.62 kB
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 "./ofetch-BIyrKU3Y.mjs"; import "./parse-date-BrP7mxXf.mjs"; import { t as cache_default } from "./cache-Bo__VnGm.mjs"; import "./helpers-DxBp0Pty.mjs"; import { r as getSubPath } from "./common-utils-vrWQFAEk.mjs"; import { t as art } from "./render-BQo6B4tL.mjs"; import { t as got_default } from "./got-KxxWdaxq.mjs"; import path from "node:path"; import { load } from "cheerio"; //#region lib/routes/itch/index.ts init_esm_shims(); const route = { path: "*", name: "Unknown", maintainers: [], handler }; async function handler(ctx) { const currentUrl = `https://itch.io${getSubPath(ctx)}`; const $ = load((await got_default({ method: "get", url: currentUrl })).data); let items = $(".title.game_link").toArray().map((item) => { item = $(item); return { title: item.text(), link: item.attr("href") }; }); items = await Promise.all(items.map((item) => cache_default.tryGet(item.link, async () => { const content = load((await got_default({ method: "get", url: item.link })).data); item.author = content("title").text().split("by ").pop(); item.description = art(path.join(__dirname, "templates/description-6541c218.art"), { images: content(".screenshot").toArray().map((i) => content(i).attr("src")), description: content(".formatted_description").html() }); return item; }))); return { title: $("title").text(), link: currentUrl, item: items }; } //#endregion export { route };