rsshub
Version:
Make RSS Great Again!
63 lines (61 loc) • 2.28 kB
JavaScript
import { n as init_esm_shims, t as __dirname } from "./esm-shims-CzJ_djXG.mjs";
import "./config-C37vj7VH.mjs";
import "./dist-BInvbO1W.mjs";
import "./logger-Czu8UMNd.mjs";
import "./ofetch-BIyrKU3Y.mjs";
import { n as parseRelativeDate, t as parseDate } from "./parse-date-BrP7mxXf.mjs";
import "./helpers-DxBp0Pty.mjs";
import { t as art } from "./render-BQo6B4tL.mjs";
import { t as got_default } from "./got-KxxWdaxq.mjs";
import { t as timezone } from "./timezone-D8cuwzTY.mjs";
import path from "node:path";
import { load } from "cheerio";
//#region lib/routes/qidian/author.ts
init_esm_shims();
const route = {
path: "/author/:id",
categories: ["reading"],
example: "/qidian/author/9639927",
parameters: { id: "作者 id, 可在作者页面 URL 找到" },
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false
},
radar: [{ source: ["my.qidian.com/author/:id"] }],
name: "作者",
maintainers: ["miles170"],
handler
};
async function handler(ctx) {
const currentUrl = `https://my.qidian.com/author/${ctx.req.param("id")}/`;
const $ = load((await got_default(currentUrl)).data);
const authorName = $(".header-msg h1").contents().first().text().trim();
const items = $(".author-work .author-item").toArray().map((item) => {
item = $(item);
const messageItem = item.find(".author-item-msg");
const updatedDate = messageItem.find(".author-item-update span").text().replace("·", "").trim();
return {
title: messageItem.find(".author-item-title").text().trim(),
author: authorName,
category: messageItem.find(".author-item-exp a").first().text().trim(),
description: art(path.join(__dirname, "templates/description-9e9a1db4.art"), {
description: messageItem.find(".author-item-update a").attr("title"),
image: item.find("a img").attr("src")
}),
pubDate: timezone(/(今|昨)/.test(updatedDate) ? parseRelativeDate(updatedDate) : parseDate(updatedDate, "YYYY-MM-DD HH:mm"), 8),
link: messageItem.find(".author-item-update a").attr("href")
};
});
return {
title: `${authorName} - 起点中文网`,
description: $(".header-msg-desc").text().trim(),
link: currentUrl,
item: items
};
}
//#endregion
export { route };