rsshub
Version:
Make RSS Great Again!
68 lines (66 loc) • 1.91 kB
JavaScript
import "./esm-shims-CzJ_djXG.mjs";
import { t as config } from "./config-C37vj7VH.mjs";
import "./dist-BInvbO1W.mjs";
import "./logger-Czu8UMNd.mjs";
import "./ofetch-BIyrKU3Y.mjs";
import { t as parseDate } from "./parse-date-BrP7mxXf.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/lightnovel/light-novel.ts
const route = {
path: "/:keywords/:security_key?",
radar: [{
source: ["lightNovel.us/"],
target: "/:keywords/:security_key"
}],
name: "Unknown",
maintainers: ["nightmare-mio"],
handler,
url: "lightNovel.us/"
};
async function handler(ctx) {
const baseUrl = "https://www.lightnovel.us";
const { type, keywords, security_key = config.lightnovel.cookie } = ctx.req.param();
const { data: response } = await got_default({
method: "POST",
url: `${baseUrl}/proxy/api/search/search-result`,
headers: { "User-Agent": config.trueUA },
json: {
is_encrypted: 0,
platform: "pc",
client: "web",
sign: "",
gz: 0,
d: {
q: keywords,
type: 0,
page: 1,
security_key
}
}
});
const list = response.data.articles.map((item) => ({
title: item.title,
link: `${baseUrl}/cn/detail/${item.aid}`,
pubDate: parseDate(item.time),
author: item.author
})).slice(0, ctx.req.query("limit") ? Number.parseInt(ctx.req.query("limit")) : 5);
const items = await Promise.all(list.map((item) => cache_default.tryGet(item.link, async () => {
const { data: response$1 } = await got_default({
method: "GET",
url: item.link,
headers: { "User-Agent": config.trueUA }
});
item.description = load(response$1)("#article-main-contents").html();
return item;
})));
return {
title: `轻之国度-追踪${keywords}更新-${type} `,
link: baseUrl,
item: items
};
}
//#endregion
export { route };