rsshub
Version:
Make RSS Great Again!
85 lines (83 loc) • 3.53 kB
JavaScript
import "./esm-shims-CzJ_djXG.mjs";
import { t as config } from "./config-C37vj7VH.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 "./helpers-DxBp0Pty.mjs";
import "./render-BQo6B4tL.mjs";
import "./proxy-Db7uGcYb.mjs";
import { t as got_default } from "./got-KxxWdaxq.mjs";
import { t as config_not_found_default } from "./config-not-found-Dyp3RlZZ.mjs";
import "./puppeteer-DGmvuGvT.mjs";
import { r as utils_default } from "./utils-XRYoJEu4.mjs";
import { t as cache_default } from "./cache-COvn8_4R.mjs";
//#region lib/routes/bilibili/followings-video.ts
const route = {
path: "/followings/video/:uid/:embed?",
categories: ["social-media"],
example: "/bilibili/followings/video/2267573",
parameters: {
uid: "用户 id",
embed: "默认为开启内嵌视频,任意值为关闭"
},
features: {
requireConfig: [{
name: "BILIBILI_COOKIE_*",
description: `BILIBILI_COOKIE_{uid}: 用于用户关注动态系列路由,对应 uid 的 b 站用户登录后的 Cookie 值,\`{uid}\` 替换为 uid,如 \`BILIBILI_COOKIE_2267573\`,获取方式:
1. 打开 [https://api.vc.bilibili.com/dynamic_svr/v1/dynamic_svr/dynamic_new?uid=0&type=8](https://api.vc.bilibili.com/dynamic_svr/v1/dynamic_svr/dynamic_new?uid=0&type=8)
2. 打开控制台,切换到 Network 面板,刷新
3. 点击 dynamic_new 请求,找到 Cookie
4. 视频和专栏,UP 主粉丝及关注只要求 \`SESSDATA\` 字段,动态需复制整段 Cookie`
}],
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false
},
name: "用户关注视频动态",
maintainers: ["LogicJake"],
handler,
description: `::: warning
用户动态需要 b 站登录后的 Cookie 值,所以只能自建,详情见部署页面的配置模块。
:::`
};
async function handler(ctx) {
const uid = String(ctx.req.param("uid"));
const embed = !ctx.req.param("embed");
const name = await cache_default.getUsernameFromUID(uid);
const cookie = config.bilibili.cookies[uid];
if (cookie === void 0) throw new config_not_found_default("缺少对应 uid 的 Bilibili 用户登录后的 Cookie 值");
const data = (await got_default({
method: "get",
url: `https://api.vc.bilibili.com/dynamic_svr/v1/dynamic_svr/dynamic_new?uid=${uid}&type=8`,
headers: {
Referer: `https://space.bilibili.com/${uid}/`,
Cookie: cookie
}
})).data;
if (data.code) {
logger_default.error(JSON.stringify(data));
if (data.code === -6 || data.code === 41e5) throw new config_not_found_default("对应 uid 的 Bilibili 用户的 Cookie 已过期");
throw new Error(`Got error code ${data.code} while fetching: ${data.message}`);
}
const out = data.data.cards.map((card) => {
const card_data = JSON.parse(card.card);
return {
title: card_data.title,
description: utils_default.renderUGCDescription(embed, card_data.pic, card_data.desc, card_data.aid, void 0, card.desc.bvid),
pubDate: (/* @__PURE__ */ new Date(card_data.pubdate * 1e3)).toUTCString(),
link: card_data.pubdate > utils_default.bvidTime && card.desc.bvid ? `https://www.bilibili.com/video/${card.desc.bvid}` : `https://www.bilibili.com/video/av${card_data.aid}`,
author: card.desc.user_profile.info.uname
};
});
return {
title: `${name} 关注视频动态`,
link: `https://t.bilibili.com/?tab=8`,
item: out
};
}
//#endregion
export { route };