UNPKG

rsshub

Version:
139 lines (130 loc) 6.74 kB
import { t as rofetch } from "./ofetch-C3ts-Hud.mjs"; import { t as parseDate } from "./parse-date-Cr0wQjV_.mjs"; import { t as cache_default } from "./cache-BkqOokyU.mjs"; import { t as timezone } from "./timezone-BBvDwS_3.mjs"; import { load } from "cheerio"; //#region lib/routes/2048/index.tsx const route = { path: "/:id?", categories: ["multimedia"], example: "/2048/2", parameters: { id: "板块 ID, 见下表,默认为最新合集,即 `3`,亦可在 URL 中找到, 例如, `thread.php?fid-3.html`中, 板块 ID 为`3`" }, features: { requireConfig: false, requirePuppeteer: false, antiCrawler: false, supportBT: true, supportPodcast: false, supportScihub: false, nsfw: true }, name: "论坛", maintainers: ["nczitzk"], handler, description: `| 最新合集 | 亞洲無碼 | 日本騎兵 | 歐美新片 | 國內原創 | 中字原創 | 三級寫真 | | -------- | -------- | -------- | -------- | -------- | -------- | -------- | | 3 | 4 | 5 | 13 | 15 | 16 | 18 | | 有碼.HD | 亞洲 SM.HD | 日韓 VR/3D | 歐美 VR/3D | S-cute / Mywife / G-area | | ------- | ---------- | ---------- | ---------- | ------------------------ | | 116 | 114 | 96 | 97 | 119 | | 網友自拍 | 亞洲激情 | 歐美激情 | 露出偷窺 | 高跟絲襪 | 卡通漫畫 | 原創达人 | | -------- | -------- | -------- | -------- | -------- | -------- | -------- | | 23 | 24 | 25 | 26 | 27 | 28 | 135 | | 唯美清純 | 网络正妹 | 亞洲正妹 | 素人正妹 | COSPLAY | 女优情报 | Gif 动图 | | -------- | -------- | -------- | -------- | ------- | -------- | -------- | | 21 | 274 | 276 | 277 | 278 | 29 | | | 獨家拍攝 | 稀有首發 | 网络见闻 | 主播實錄 | 珍稀套圖 | 名站同步 | 实用漫画 | | -------- | -------- | -------- | -------- | -------- | -------- | -------- | | 213 | 94 | 283 | 111 | 88 | 131 | 180 | | 网盘二区 | 网盘三区 | 分享福利 | 国产精选 | 高清福利 | 高清首发 | 多挂原创 | | -------- | -------- | -------- | -------- | -------- | -------- | -------- | | 72 | 272 | 195 | 280 | 79 | 216 | 76 | | 磁链迅雷 | 正片大片 | H-GAME | 有声小说 | 在线视频 | 在线快播影院 | | -------- | -------- | ------ | -------- | -------- | ------------ | | 43 | 67 | 66 | 55 | 78 | 279 | | 综合小说 | 人妻意淫 | 乱伦迷情 | 长篇连载 | 文学作者 | TXT 小说打包 | | -------- | -------- | -------- | -------- | -------- | ------------ | | 48 | 103 | 50 | 54 | 100 | 109 | | 聚友客栈 | 坛友自售 | | -------- | -------- | | 57 | 136 |` }; async function handler(ctx) { const id = ctx.req.param("id") ?? "3"; const rootUrl = "https://hjd2048.com"; const domainInfo = await cache_default.tryGet("2048:domainInfo", async () => { const targetUrl = load(await rofetch("https://2048.info"))(".button").first().attr("onclick")?.match(/window\.open\('([^']+)'/)?.[1]; return { url: new URL(targetUrl, "https://2048.info").href }; }); const redirectResponse = await rofetch.raw(domainInfo.url); const redirected = await cache_default.tryGet(`2048:redirected:${new URL(redirectResponse.url).host}`, async () => { const safeidMatch = load(await rofetch(redirectResponse.url)).html()?.match(/var\s+safeid\s*=\s*'([^']+)'/); const safeid = safeidMatch ? safeidMatch[1] : void 0; return { url: redirectResponse.url, safeid }; }, 86400, false); const currentUrl = `${redirected.url}thread.php?fid-${id}.html`; const response = await rofetch.raw(currentUrl, { headers: { cookie: `_safe=${redirected.safeid}` } }); const $ = load(response._data); const currentHost = `https://${new URL(response.url).host}`; $("#shortcut").remove(); $("tr[onmouseover=\"this.className='tr3 t_two'\"]").remove(); const list = $("#ajaxtable tbody .tr2").last().nextAll(".tr3").toArray().map((item) => { const $item = $(item).find("a.subject"); return { title: $item.text(), link: `${currentHost}/${$item.attr("href")}`, guid: `${rootUrl}/2048/${$item.attr("href")}` }; }).filter((item) => !item.link.includes("undefined")); const items = await Promise.all(list.map((item) => cache_default.tryGet(item.guid, async () => { const content = load(await rofetch(item.link, { headers: { cookie: `_safe=${redirected.safeid}` } })); content(".ads, .tips").remove(); content("ignore_js_op").each((_, el) => { const img = content(el).find("img"); const originalSrc = img.attr("data-original"); const fallbackSrc = img.attr("src"); const imgSrc = originalSrc || fallbackSrc; content(el).replaceWith(`<img src="${imgSrc}">`); }); item.author = content(".fl.black").first().text(); item.pubDate = timezone(parseDate(content("span.fl.gray").first().attr("title")), 8); const readTpc = content("#read_tpc").first(); const copyLink = content("#copytext")?.first()?.text(); const readTpcHtml = readTpc.html() ?? ""; const magnetText = readTpc.find(".magnet-text").first().text().trim(); const rmdownLink = readTpc.find("a[href*=\"rmdown.com/link.php\"]").first().attr("href"); const enclosureHref = rmdownLink?.startsWith("http") ? rmdownLink : rmdownLink ? `https://www.rmdown.com/${rmdownLink}` : null; if (enclosureHref) { const btihMatch = (await cache_default.tryGet(`2048:rmdown:${enclosureHref}`, () => rofetch(enclosureHref))).match(/Code:\s*([a-fA-F0-9]{40})/); const magnetUrl = btihMatch ? `magnet:?xt=urn:btih:${btihMatch[1]}` : null; if (magnetUrl) { item.enclosure_url = magnetUrl; item.enclosure_type = "x-scheme-handler/magnet"; } } if (!item.enclosure_url) { const hashMatch = readTpcHtml.match(/哈希校验[^;]*;\s*([a-f0-9]{40})\s*[;;]/i); const magnetFromHash = hashMatch ? `magnet:?xt=urn:btih:${hashMatch[1]}` : null; const magnetLink = magnetText.match(/magnet:\?xt=urn:btih:[^\s"'<>]+/)?.[0] ?? readTpcHtml.match(/magnet:\?xt=urn:btih:[^\s"'<>]+/)?.[0] ?? magnetFromHash ?? copyLink; if (magnetLink?.startsWith("magnet")) { item.enclosure_url = magnetLink; item.enclosure_type = "x-scheme-handler/magnet"; } } content(".showhide img").each((_, el) => { readTpc.append(`<br><img style="max-width: 100%;" src="${content(el).attr("src")}">`); }); item.description = readTpc.html(); return item; }))); return { title: `${$("#main #breadCrumb a").last().text()} - 2048核基地`, link: currentUrl, item: items }; } //#endregion export { route };