rsshub
Version:
Make RSS Great Again!
95 lines (93 loc) • 3.72 kB
JavaScript
import "./esm-shims-CzJ_djXG.mjs";
import { t as config } from "./config-C37vj7VH.mjs";
import { t as ViewType } from "./types-D84BRIt4.mjs";
import "./dist-BInvbO1W.mjs";
import { t as logger_default } from "./logger-Czu8UMNd.mjs";
import "./ofetch-BIyrKU3Y.mjs";
import "./md5-C8GRvctM.mjs";
import "./cache-Bo__VnGm.mjs";
import { a as parseDuration } from "./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 { n as getVideoUrl, r as utils_default } from "./utils-XRYoJEu4.mjs";
import { t as cache_default } from "./cache-COvn8_4R.mjs";
//#region lib/routes/bilibili/video.ts
const route = {
path: "/user/video/:uid/:embed?",
categories: ["social-media"],
view: ViewType.Videos,
example: "/bilibili/user/video/2267573",
parameters: {
uid: "用户 id, 可在 UP 主主页中找到",
embed: "默认为开启内嵌视频, 任意值为关闭"
},
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false
},
radar: [{
source: ["space.bilibili.com/:uid"],
target: "/user/video/:uid"
}],
name: "UP 主投稿",
maintainers: [
"DIYgod",
"Konano",
"pseudoyu"
],
handler
};
async function handler(ctx) {
const isJsonFeed = ctx.req.query("format") === "json";
const uid = ctx.req.param("uid");
const embed = !ctx.req.param("embed");
const cookie = await cache_default.getCookie();
const wbiVerifyString = await cache_default.getWbiVerifyString();
const dmImgList = utils_default.getDmImgList();
const dmImgInter = utils_default.getDmImgInter();
const renderData = await cache_default.getRenderData(uid);
const data = (await got_default(`https://api.bilibili.com/x/space/wbi/arc/search?${utils_default.addWbiVerifyInfo(utils_default.addRenderData(utils_default.addDmVerifyInfoWithInter(`mid=${uid}&ps=30&tid=0&pn=1&keyword=&order=pubdate&platform=web&web_location=1550101&order_avoided=true`, dmImgList, dmImgInter), renderData), wbiVerifyString)}`, { headers: {
Referer: `https://space.bilibili.com/${uid}`,
origin: `https://space.bilibili.com`,
Cookie: cookie
} })).data;
if (data.code) {
logger_default.error(JSON.stringify(data.data));
throw new Error(`Got error code ${data.code} while fetching: ${data.message}`);
}
const usernameAndFace = await cache_default.getUsernameAndFaceFromUID(uid);
const name = usernameAndFace[0] || data.data.list.vlist[0]?.author;
const face = usernameAndFace[1];
return {
title: `${name} 的 bilibili 空间`,
link: `https://space.bilibili.com/${uid}`,
description: `${name} 的 bilibili 空间`,
image: face ?? void 0,
logo: face ?? void 0,
icon: face ?? void 0,
item: data.data && data.data.list && data.data.list.vlist && await Promise.all(data.data.list.vlist.map(async (item) => {
const subtitles = isJsonFeed && !config.bilibili.excludeSubtitles && item.bvid ? await cache_default.getVideoSubtitleAttachment(item.bvid) : [];
return {
title: item.title,
description: utils_default.renderUGCDescription(embed, item.pic, item.description, item.aid, void 0, item.bvid),
pubDate: (/* @__PURE__ */ new Date(item.created * 1e3)).toUTCString(),
link: item.created > utils_default.bvidTime && item.bvid ? `https://www.bilibili.com/video/${item.bvid}` : `https://www.bilibili.com/video/av${item.aid}`,
author: name,
comments: item.comment,
attachments: item.bvid ? [{
url: getVideoUrl(item.bvid),
mime_type: "text/html",
duration_in_seconds: parseDuration(item.length)
}, ...subtitles] : void 0
};
}))
};
}
//#endregion
export { route };