npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

dsh-bilibili-plugin

v1.0.1

Published

Bilibili operator toolkit for DSH — QR login, comments, DMs, fans, danmaku, video analytics. Registers 17 tools + 1 skill.

Readme

dsh-bilibili-plugin

给 DSH 注册一套 B站操作工具 + 一个 Skill。安装后直接对 DSH 说「帮我登录B站」「看看这个视频的数据」「回一下这条评论」就行。

装了什么

17 个工具 + 1 个 Skill。

| 分类 | 工具 | 作用 | |---|---|---| | 认证 | bilibili_login | 发起扫码登录,返回二维码链接 | | | bilibili_login_poll | 轮询扫码状态,确认后自动保存 cookie | | | bilibili_status | 检查登录状态、账号信息、粉丝数 | | | bilibili_logout | 清除本地凭证 | | 账号 | bilibili_me | 获取自己账号详情 | | | bilibili_my_videos | 查投稿列表和审核状态 | | 视频 | bilibili_video_info | 查视频详情(标题、UP主、播放、点赞、评论数) | | 评论 | bilibili_list_comments | 读评论列表 | | | bilibili_comment | 发表评论 | | | bilibili_like_comment | 评论点赞/取消 | | | bilibili_delete_comment | 删除自己的评论 | | 私信 | bilibili_send_dm | 发私信 | | | bilibili_list_sessions | 列出会话 | | | bilibili_read_messages | 读对话内容 | | 粉丝 | bilibili_list_fans | 列出粉丝 | | | bilibili_follow | 关注/取关 | | 弹幕 | bilibili_send_danmaku | 发弹幕 |

安装

方式一:本地目录(开发用)

git clone <本仓库> dsh-bilibili-plugin
cd dsh-bilibili
bash scripts/install.sh

然后编辑 ~/.dsh/profiles/<你的profile>/package.json:

{
  "dependencies": {
    "dsh-bilibili-plugin": "link:/绝对路径/dsh-bilibili-plugin"
  },
  "dsh": {
    "profile": {
      "bundles": ["...", "dsh-bilibili"]
    }
  }
}

然后:

cd ~/.dsh/profiles/<你的profile>
pnpm install

重启 DSH。

方式二:npm(推荐)

# 在你的 DSH profile 目录下
pnpm add dsh-bilibili-plugin

然后在 ~/.dsh/profiles/<你的profile>/package.json 的 dsh.profile.bundles 里加入:

"dsh-bilibili-plugin"

使用

装好后直接跟 DSH 说话就行:

登录

帮我登录B站

DSH 会调用 bilibili_login 生成二维码,转成图片发给你,你扫码确认,自动完成授权。

看数据

帮我看看这个视频的数据 https://b23.tv/xxxxx

回评论

帮我回复这个视频下的评论

发私信

给最新关注的粉丝发条私信

配置

可选配置项(在 profile 的 cordis.patch.yml 里加):

- id: dsh-bilibili
  config:
    cookieFile: ~/.dsh-bilibili/cookies/default.json
    timeout: 30000

| 配置 | 默认值 | 说明 | |---|---|---| | cookieFile | ~/.dsh-bilibili/cookies/default.json | cookie 存放路径 | | timeout | 30000 | HTTP 超时(毫秒) |

从 social-auto-upload 迁移 cookie

如果你之前用过 social-auto-upload:

mkdir -p ~/.dsh-bilibili/cookies
cp /path/to/social-auto-upload/cookies/bilibili_<账号名>.json \
   ~/.dsh-bilibili/cookies/default.json

cookie 格式是兼容的(都是 biliup 格式)。

设计说明

为什么不依赖 biliup 二进制?

登录用纯 HTTP 实现(TV 端扫码接口 + MD5 签名),不需要下载 55MB 的 Rust 二进制。安装更轻,跨平台更简单。

为什么不包含发视频?

视频上传涉及分片、断点续传、大文件处理。这部分用成熟工具更可靠:

本插件专注操作类接口(评论、私信、数据查询),这部分没有现成工具,也是日常运营最高频的。

已知坑

1. 不要反复验证登录状态

B站的 refresh token 是一次性的。反复刷新会让旧 token 作废,把有效凭证刷死。

需要确认状态时用 bilibili_status(只调 nav 接口,不消耗 token)。

2. 公开评论区不要发链接

在别人视频下发网盘链接、联系方式,容易判定为引流违规。

  • 公开评论:只做内容互动
  • 资源分发:走私信

3. 私信有频率限制

新账号私信有频次限制(估计几十条/天)。不要批量群发。

4. aid 和 bvid 不一样

  • bvid:BV1xx411c7mD,用户看到的是这个
  • aid:数字 ID,接口要这个

用 bilibili_video_info 传 bvid,返回里有 aid。

开发

src/
├── index.js      # 插件入口,导出 apply/inject/name/Config
├── client.js     # HTTP 客户端,封装所有 B站接口
├── auth.js       # 扫码登录(纯 HTTP)
└── tools.js      # 17 个工具定义

skills/bilibili/
└── SKILL.md      # 告诉 AI 怎么用这些工具

本地测试:

node --input-type=module -e "
const registered = [];
const ctx = { tools: { register: (t) => registered.push(t) }, logger: { info(){} } };
const { apply } = await import('./src/index.js');
apply(ctx, {});
console.log('注册了', registered.length, '个工具');
"

License

MIT