UNPKG

rsshub

Version:
56 lines (55 loc) 1.69 kB
import { t as parseDate } from "./parse-date-3kcy2Eau.mjs"; import { t as cache_default } from "./cache-C1Y-9qDV.mjs"; import { t as got_default } from "./got-DUpa1V3-.mjs"; import { t as timezone } from "./timezone-UiMFOuvL.mjs"; import { load } from "cheerio"; //#region lib/routes/zhibo8/forum.ts const route = { path: "/forum/:id", categories: ["bbs"], example: "/zhibo8/forum/8", parameters: { id: "子论坛 id,可在子论坛 URL 找到" }, features: { requireConfig: false, requirePuppeteer: false, antiCrawler: false, supportBT: false, supportPodcast: false, supportScihub: false }, name: "子论坛", maintainers: ["LogicJake"], handler }; async function handler(ctx) { const link = `https://bbs.zhibo8.cc/forum/list/?fid=${ctx.req.param("id")}`; const response = await got_default(link); const $ = load(response.data); const title = $("div.intro > h2").text(); const list = $("table.topic-list > tbody:nth-child(3) > tr"); const out = await Promise.all(list.toArray().map((item) => { const $item = $(item); const a = $item.find("td:nth-child(1) > a:nth-child(2)"); const link = "https://bbs.zhibo8.cc" + a.attr("href"); return cache_default.tryGet(link, async () => { const title = a.text(); const author = $item.find("td:nth-child(2) cite a").text(); const date = $item.find("td:nth-child(2) em").text(); const response = await got_default(link); return { title, description: load(response.data)(".detail_ent").html(), author, link, pubDate: timezone(parseDate(date, "YYYY-MM-DD HH:mm"), 8) }; }); })); return { title: `${title}—直播吧`, link, item: out }; } //#endregion export { route };