UNPKG

rsshub

Version:
54 lines (52 loc) 1.88 kB
import "./esm-shims-CzJ_djXG.mjs"; import "./config-C37vj7VH.mjs"; import "./dist-BInvbO1W.mjs"; import "./logger-Czu8UMNd.mjs"; import "./ofetch-BIyrKU3Y.mjs"; import { t as parseDate } from "./parse-date-BrP7mxXf.mjs"; import { t as cache_default } from "./cache-Bo__VnGm.mjs"; import "./helpers-DxBp0Pty.mjs"; import { t as got_default } from "./got-KxxWdaxq.mjs"; import { t as timezone } from "./timezone-D8cuwzTY.mjs"; import { load } from "cheerio"; //#region lib/routes/indienova/gamedb.ts const route = { path: "/gamedb/recent", name: "Unknown", maintainers: ["TonyRL"], handler }; async function handler(ctx) { const { platform = "all" } = ctx.req.param(); const baseUrl = "https://indienova.com"; const { data: response, url: link } = await got_default(`${baseUrl}/gamedb/recent/${platform}/p/1`); const $ = load(response); const list = $(".related-game").toArray().map((item) => { item = $(item); return { title: item.find("span").contents().filter((_, el) => el.nodeType === 3).text(), link: new URL(item.find("a").attr("href"), baseUrl).href }; }); const items = await Promise.all(list.map((item) => cache_default.tryGet(item.link, async () => { const { data: response$1 } = await got_default(item.link); const $$1 = load(response$1); const featureBox = $$1(".feature-box"); if (featureBox.length) { item.description = featureBox.find("p").first().text(); return item; } const article = $$1(".row article"); article.find("#showHiddenText").remove(); item.description = $$1(".cover-image").prop("outerHTML") + $$1(".tab-container").html() + article.html(); item.pubDate = $$1(".gamedb-release").length ? timezone(parseDate($$1(".gamedb-release").text().replaceAll(/[()]/g, "")), 8) : null; return item; }))); return { title: $("head title").text(), link, item: items }; } //#endregion export { route };