UNPKG

rsshub

Version:
83 lines (81 loc) 3.1 kB
import { t as rofetch } from "./ofetch-U0CdpE2g.mjs"; import { t as parseDate } from "./parse-date-3kcy2Eau.mjs"; import { t as cache_default } from "./cache-C1Y-9qDV.mjs"; import { t as timezone } from "./timezone-UiMFOuvL.mjs"; import { load } from "cheerio"; import iconv from "iconv-lite"; //#region lib/routes/sexinsex/index.ts const base = "https://sexinsex.net"; const section = "/bbs/forumdisplay.php?fid="; const fetchGbk = (url, referer) => rofetch(url, { headers: { Referer: referer }, responseType: "arrayBuffer" }); const route = { path: "/:id/:type?", categories: ["multimedia"], example: "/sexinsex/230/634", parameters: { id: "分区 id, 可在分区页 URL 中找到", type: "类型 id, 可在分区类型过滤后的 URL 中找到" }, radar: [{ source: ["sexinsex.net/bbs/:path"] }], name: "分区帖子", maintainers: ["cnzgray"], description: `> 注意:并非所有的分区都有子类型,可以参考亚洲成人有码原创区的 \`字幕\` 这一子类型。 | 亚洲成人无码原创区 | 亚洲成人有码原创区 | 欧美无码原创区 | 欧美无码区 | 亚洲有码薄码区 | | ------------------ | ------------------ | -------------- | ---------- | -------------- | | 143 | 230 | 229 | 77 | 58 |`, handler }; function parseContent(buffer) { const htmlString = iconv.decode(Buffer.from(buffer), "gbk"); let $ = load(htmlString); const author = $("#wrapper > div:nth-child(1) > form > div:nth-child(2) > table > tbody > tr:nth-child(1) > td.postauthor > cite > a").text(); const regRes = /\d{4}(?:-\d{1,2}){2} \d{1,2}:\d{1,2}/.exec($(".postinfo").text()); const content = $(".postmessage").html() ?? ""; $ = load(content); $(".postratings").remove(); $("div.quote").remove(); return { author, description: $("body").html(), pubDate: regRes ? timezone(parseDate(regRes[0]), 8) : void 0 }; } async function handler(ctx) { const { id, type } = ctx.req.param(); const typefilter = type ? `&filter=type&typeid=${type}` : ""; const pageUrl = new URL(`${section}${id}${typefilter}`, base).href; const res = await fetchGbk(pageUrl, base); const data = iconv.decode(Buffer.from(res), "gbk"); const $ = load(data); const title = (type ? `[${$(".threadlist .headactions strong").text()}]` : "") + $("title").text(); const list = $("tbody[id^=\"normalthread_\"] tr th").toArray(); return { title, link: pageUrl, item: (await Promise.all(list.map((item) => { const $item = $(item); const guid = $item.find("span[id^=\"thread_\"]").attr("id"); const itemTitle = $item.find("span a").text(); const catalog = $item.find("em").text(); const link = new URL(`/bbs/${guid.replace("_", "-")}-1-1.html`, base).href; return cache_default.tryGet(link, async () => { try { const response = await fetchGbk(link, pageUrl); return { title: `${catalog} ${itemTitle}`, link, guid, ...parseContent(response) }; } catch { return ""; } }); }))).filter((item) => item !== "") }; } //#endregion export { route };