rsshub
Version:
Make RSS Great Again!
54 lines (52 loc) • 1.5 kB
JavaScript
import "./dist-Bog6z_OM.mjs";
import "./config-MQ-7ebJ_.mjs";
import "./logger-C4avouvV.mjs";
import "./ofetch-DKl_Ma9g.mjs";
import "./parse-date-r5WDWHno.mjs";
import "./is-worker-DESPicPc.mjs";
import { t as cache_default } from "./cache-SV6W5EPy.mjs";
import "./helpers-Bo4JQYdN.mjs";
import { r as getSubPath } from "./common-utils-Cz5bFBus.mjs";
import { t as got_default } from "./got-CO-ndVl2.mjs";
import { t as renderDescription } from "./description-BAPC3chG.mjs";
import { load } from "cheerio";
//#region lib/routes/itch/index.ts
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 = renderDescription({
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 };