rsshub
Version:
Make RSS Great Again!
125 lines (123 loc) • 3.75 kB
JavaScript
import "./dist-Bog6z_OM.mjs";
import "./config-MQ-7ebJ_.mjs";
import "./logger-C4avouvV.mjs";
import "./ofetch-DKl_Ma9g.mjs";
import { t as parseDate } from "./parse-date-r5WDWHno.mjs";
import "./helpers-Bo4JQYdN.mjs";
import { t as got_default } from "./got-CO-ndVl2.mjs";
import { Fragment, jsx, jsxs } from "hono/jsx/jsx-runtime";
import { renderToString } from "hono/jsx/dom/server";
import aesjs from "aes-js";
//#region lib/routes/duozhuayu/search.tsx
const route = {
path: "/search/:wd",
categories: ["shopping"],
example: "/duozhuayu/search/JavaScript",
parameters: { wd: "搜索关键词" },
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false
},
radar: [{ source: ["duozhuayu.com/search/book/:wd"] }],
name: "搜索结果",
maintainers: ["fengkx"],
handler
};
async function handler(ctx) {
const wd = ctx.req.param("wd");
const baseUrl = "https://www.duozhuayu.com";
const type = "book";
const link = `${baseUrl}/search/${type}/${wd}`;
const key = [..."DkOliWvFNR7C4WvR"].map((c) => c.charCodeAt());
const iv = [..."GQWKUE2CVGOOBKXU"].map((c) => c.charCodeAt());
const aesCfb = new aesjs.ModeOfOperation.cfb(key, iv);
const encrypt = (text) => {
const textBytes = aesjs.utils.utf8.toBytes(text);
const encryptedBytes = aesCfb.encrypt(textBytes);
return aesjs.utils.hex.fromBytes(encryptedBytes);
};
const getCustomRequestHeaders = () => {
const timestamp = Date.now();
const userId = 0;
const securityKey = Math.floor(1e8 * Math.random());
const token = encrypt([
timestamp,
userId,
securityKey
].join(":"));
const requestId = [
userId,
timestamp,
Math.round(1e5 * Math.random())
].join("-");
return {
"x-api-version": "0.0.48",
"x-refer-request-id": requestId,
"x-request-id": requestId,
"x-request-misc": "{\"platform\":\"browser\",\"originSource\":\"search\",\"originFrom\":\"normal\",\"webVersion\":\"1.2.201774\"}",
"x-request-token": token,
"x-security-key": securityKey,
"x-timestamp": timestamp,
"x-user-id": userId
};
};
const item = (await got_default({
method: "get",
url: `${baseUrl}/api/search/book`,
searchParams: {
type: "normal",
q: wd
},
headers: getCustomRequestHeaders()
})).data.data.filter((item) => item.type === type).map(({ [type]: item }) => ({
title: item.title,
link: `${baseUrl}/books/${item.id}`,
pubDate: parseDate(item.updated),
description: renderToString(/* @__PURE__ */ jsxs("div", { children: [
/* @__PURE__ */ jsx("img", { src: item.images.origin }),
/* @__PURE__ */ jsx("br", {}),
"书名:",
item.title,
" ",
item.originalTitle,
/* @__PURE__ */ jsx("br", {}),
item.subtitle ? /* @__PURE__ */ jsxs(Fragment, { children: [item.subtitle, /* @__PURE__ */ jsx("br", {})] }) : null,
"作者:",
item.rawAuthor,
/* @__PURE__ */ jsx("br", {}),
item.translators?.length ? /* @__PURE__ */ jsxs(Fragment, { children: [
"译者:",
item.translators.map((translator) => translator.name).join(" / "),
/* @__PURE__ */ jsx("br", {})
] }) : null,
"ISBN:",
item.isbn13,
/* @__PURE__ */ jsx("br", {}),
"出版社:",
item.publisher,
/* @__PURE__ */ jsx("br", {}),
"出版时间:",
item.publishDate,
/* @__PURE__ */ jsx("br", {}),
"豆瓣评分:",
item.doubanRating,
/* @__PURE__ */ jsx("br", {}),
"价格:",
(item.price / 100).toFixed(2),
"元起 ",
/* @__PURE__ */ jsxs("del", { children: [(item.originalPrice / 100).toFixed(2), "元"] })
] }))
}));
return {
title: `多抓鱼搜索-${wd}`,
link,
description: `多抓鱼搜索-${wd}`,
item
};
}
//#endregion
export { route };