UNPKG

rsshub

Version:
75 lines (73 loc) 2.24 kB
import "./dist-Bog6z_OM.mjs"; import "./config-MQ-7ebJ_.mjs"; import "./logger-C4avouvV.mjs"; import "./ofetch-DKl_Ma9g.mjs"; import "./is-worker-DESPicPc.mjs"; import { t as cache_default } from "./cache-SV6W5EPy.mjs"; import "./helpers-Bo4JQYdN.mjs"; import { t as got_default } from "./got-CO-ndVl2.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 = 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, 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 };