UNPKG

rsshub

Version:
75 lines (73 loc) 2.25 kB
import "./esm-shims-CzJ_djXG.mjs"; import "./config-C37vj7VH.mjs"; import "./dist-BInvbO1W.mjs"; import "./logger-Czu8UMNd.mjs"; import "./ofetch-BIyrKU3Y.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 { load } from "cheerio"; //#region lib/routes/u3c3/index.ts const route = { path: ["/search/:keyword/:preview?", "/:type?/:preview?"], categories: ["multimedia"], example: "/u3c3/search/新片速递", parameters: { keyword: "Search keyword", preview: "Show image preview, off by default, non empty value means on" }, features: { requireConfig: false, requirePuppeteer: false, antiCrawler: false, supportBT: true, supportPodcast: false, supportScihub: false }, name: "Search", maintainers: ["storytellerF"], handler }; async function handler(ctx) { const { type, keywoard, preview } = ctx.req.param(); const rootURL = "https://www.u3c3.com"; let currentURL; let title; if (keywoard) { currentURL = `${rootURL}/?search=${keywoard}`; title = `search ${keywoard} - u3c3`; } else if (type === void 0) { currentURL = rootURL; title = "home - u3c3"; } else { currentURL = `${rootURL}/?type=${type}&p=1`; title = `${type} - u3c3`; } const $ = load((await got_default(currentURL)).data); const list = $("body > div.container > div.table-responsive > table > tbody > tr").toArray().map((item) => { item = $(item); const title$1 = item.find("td:nth-of-type(2) > a ").attr("title"); const guid = rootURL + item.find("td:nth-of-type(2) > a").attr("href"); return { title: title$1, guid, link: guid, pubDate: item.find("td:nth-of-type(5)").text(), enclosure_url: item.find("td:nth-of-type(3) > a:nth-of-type(2)").attr("href"), enclosure_type: "application/x-bittorrent" }; }); const items = preview ? await Promise.all(list.map((item) => cache_default.tryGet(item.link, async () => { const { data: response } = await got_default(item.link); item.description = load(response)("div.panel-footer > img:first-child").parent().html(); return item; }))) : list; return { title, description: title, link: currentURL, item: items }; } //#endregion export { route };