rsshub
Version:
Make RSS Great Again!
56 lines (54 loc) • 1.85 kB
JavaScript
import "./esm-shims-CzJ_djXG.mjs";
import { t as config } from "./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 { t as got_default } from "./got-KxxWdaxq.mjs";
import "./timezone-D8cuwzTY.mjs";
import { n as getThread, t as getCookie } from "./common-D6Q6cQeH.mjs";
import { load } from "cheerio";
//#region lib/routes/sis001/forum.ts
const route = {
path: "/forum/:id?",
categories: ["bbs"],
example: "/sis001/forum/322",
parameters: { id: "子版块 ID,可在子论坛 URL 找到,默认为 `Funny Jokes | 短篇笑话区`" },
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false,
nsfw: true
},
name: "子版块",
maintainers: ["TonyRL"],
handler
};
async function handler(ctx) {
const { id = 76 } = ctx.req.param();
const url = `${config.sis001.baseUrl}/forum/forum-${id}-1.html`;
const cookie = await getCookie(url);
const $ = load((await got_default(url, { headers: { cookie } })).data);
let items = $("form table").last().find("tbody").toArray().slice(1).map((item) => {
item = $(item);
return {
title: item.find("th em").text() + " " + item.find("span a").eq(0).text(),
link: new URL(item.find("span a").eq(0).attr("href"), `${config.sis001.baseUrl}/forum/`).href,
author: item.find(".author a").text()
};
});
items = await Promise.all(items.map((item) => cache_default.tryGet(item.link, async () => await getThread(cookie, item))));
return {
title: $("head title").text(),
description: $("meta[name=description]").attr("content"),
link: url,
item: items
};
}
//#endregion
export { route };