UNPKG

rsshub

Version:
47 lines (45 loc) 1.53 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 "./got-CO-ndVl2.mjs"; import { t as utils_default } from "./utils-tB0RELOG.mjs"; import { load } from "cheerio"; //#region lib/routes/pianyuan/search.ts const route = { path: "/indexers/pianyuan/results/search/api", radar: [{ source: ["pianyuan.org/"], target: "/index" }], name: "Unknown", maintainers: ["jerry1119"], handler, url: "pianyuan.org/" }; async function handler(ctx) { const link_base = "https://pianyuan.org/"; const description = "搜索"; const link = `https://pianyuan.org/search?q=${ctx.originalUrl.split("&q=")[1]}`; const $ = load((await utils_default.request(link, cache_default)).data); const searchLinks = $(".nomt > a").toArray().map((a) => $(a).attr("href")); if (searchLinks.length === 0) throw new Error("pianyuan 搜索失败"); const detailLinks = []; await Promise.all(searchLinks.map(async (e) => { const link = new URL(e, link_base).href; return await cache_default.tryGet(link, async () => { load((await utils_default.request(link, cache_default)).data)(".ico.ico_bt").toArray().map((a) => detailLinks.push($(a).attr("href"))); }); })); return { title: "片源网", description, link: link_base, item: await utils_default.ProcessFeed(detailLinks, cache_default) }; } //#endregion export { route };