rsshub
Version:
Make RSS Great Again!
48 lines (46 loc) • 1.58 kB
JavaScript
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 "./got-KxxWdaxq.mjs";
import "./config-not-found-Dyp3RlZZ.mjs";
import { t as utils_default } from "./utils-CustOe3q.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$1 = new URL(e, link_base).href;
return await cache_default.tryGet(link$1, async () => {
load((await utils_default.request(link$1, 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 };