rsshub
Version:
Make RSS Great Again!
80 lines (78 loc) • 2.48 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 parseDate } from "./parse-date-BrP7mxXf.mjs";
import "./md5-C8GRvctM.mjs";
import { t as cache_default } from "./cache-Bo__VnGm.mjs";
import "./helpers-DxBp0Pty.mjs";
import "./render-BQo6B4tL.mjs";
import "./proxy-Db7uGcYb.mjs";
import { t as got_default } from "./got-KxxWdaxq.mjs";
import "./puppeteer-DGmvuGvT.mjs";
import "./utils-XRYoJEu4.mjs";
import { t as cache_default$1 } from "./cache-COvn8_4R.mjs";
import { load } from "cheerio";
//#region lib/routes/bilibili/article.ts
const route = {
path: "/user/article/:uid",
categories: ["social-media"],
example: "/bilibili/user/article/334958638",
parameters: { uid: "用户 id, 可在 UP 主主页中找到" },
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false
},
radar: [{ source: ["space.bilibili.com/:uid"] }],
name: "UP 主图文",
maintainers: [
"lengthmin",
"Qixingchen",
"hyoban"
],
handler
};
async function handler(ctx) {
const uid = ctx.req.param("uid");
const name = await cache_default$1.getUsernameFromUID(uid);
const data = (await got_default({
method: "get",
url: `https://api.bilibili.com/x/polymer/web-dynamic/v1/opus/feed/space?host_mid=${uid}`,
headers: { Referer: `https://space.bilibili.com/${uid}/article` }
})).data.data;
const title = `${name} 的 bilibili 图文`;
const link = `https://space.bilibili.com/${uid}/article`;
const description = `${name} 的 bilibili 图文`;
const cookie = await cache_default$1.getCookie();
return {
title,
link,
description,
item: await Promise.all(data.items.map(async (item) => {
const link$1 = "https:" + item.jump_url;
const $ = load(await cache_default.tryGet(link$1, async () => (await got_default({
method: "get",
url: link$1,
headers: {
Referer: `https://space.bilibili.com/${uid}/article`,
Cookie: cookie
}
})).data));
const description$1 = $(".opus-module-content").html();
const pubDate = $(".opus-module-author__pub__text").text().replace("编辑于 ", "");
return {
title: item.content,
link: link$1,
description: description$1 || item.content,
pubDate: pubDate ? parseDate(pubDate, "YYYY年MM月DD日 HH:mm") : void 0
};
}))
};
}
//#endregion
export { route };