rsshub
Version:
Make RSS Great Again!
64 lines (62 loc) • 2.31 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 { n as parseRelativeDate, 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 { t as timezone } from "./timezone-D8cuwzTY.mjs";
import { load } from "cheerio";
//#region lib/routes/oschina/user.ts
const route = {
path: ["/u/:uid", "/user/:id"],
categories: ["programming"],
example: "/oschina/u/3920392",
parameters: { uid: "用户 id,可通过查看用户博客网址得到,以 u/数字结尾,数字即为 id" },
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false
},
radar: [{ source: ["my.oschina.net/u/:uid"] }],
name: "数字型账号用户博客",
maintainers: [],
handler
};
async function handler(ctx) {
const { id, uid } = ctx.req.param();
const $ = load((id ? await got_default(`https://my.oschina.net/${id}`) : await got_default(`https://my.oschina.net/u/${uid}`)).data);
const author = $(".user-name .name").text();
const list = $("#newestBlogList .blog-item").toArray().map((item) => {
item = $(item);
const date = item.find(".extra div .item:nth-of-type(2)").text();
const accessible = !item.find("div.label[data-tooltip=审核中]").length;
item.find(".label").remove();
return {
title: item.find(".content a.header").text(),
description: item.find(".description p").text(),
link: item.find("a.header").attr("href"),
pubDate: timezone(/\//.test(date) ? parseDate(date, ["YYYY/MM/DD HH:mm", "MM/DD HH:mm"]) : parseRelativeDate(date), 8),
author,
accessible
};
});
const resultItem = await Promise.all(list.map((item) => cache_default.tryGet(item.link, async () => {
if (item.accessible) item.description = load((await got_default(item.link)).data)(".article-detail").html();
delete item.accessible;
return item;
})));
return {
title: author + "的博客",
description: $(".user-text .user-signature").text(),
link: `https://my.oschina.net/u/${id ?? uid}`,
item: resultItem
};
}
//#endregion
export { route };