Community plugin

TimYi / dsh-plugin-bilibili-subtitle

Bilibili subtitle extraction for DSH: official CC/AI subtitle track, with local SenseVoice ASR fallback

  • JavaScript
  • MIT
  • 0 stars
  • Nov 8, 2026

About this plugin

Written by the registry from verified metadata, not from the README.

dsh-plugin-bilibili-subtitle is a DSH plugin published from the TimYi/dsh-plugin-bilibili-subtitle repository.

  • Listing statusManifest verified
  • Manifest checkedNov 13, 2026
  • Packagedsh-plugin-bilibili-subtitle
  • Package version0.1.0
  • DSH engine>=0.2.0
  • Source commita0dd267
  • Repository createdNov 8, 2026

Capabilities and topics

dshdsh-pluginbilibilisubtitle
From the repository README

README

Everything below this line is the repository's own document, cached here. This site did not write or review it.

dsh-plugin-bilibili-subtitle

给 DeepSeek Harness(DSH)用的 B 站字幕提取插件。 丢一个视频链接或 BV 号,工作区里就会多出 .srt 和 .txt。

  • 优先取 B 站官方 CC / AI 字幕(自动 wbi 签名);
  • 没有官方字幕时,下载音轨并用 SenseVoice-small 本地转写(CPU,不需要显卡、不需要登录)。

安装

从插件市场索引安装

把下面这个索引地址加到 DSH 设置 → 插件 → 索引(Discover)里:

https://raw.githubusercontent.com/TimYi/dsh-plugin-bilibili-subtitle/main/market/index.json

然后在 Discover 里搜索「B 站字幕」安装。

从 Git 安装

dsh plugin install "git+https://github.com/TimYi/dsh-plugin-bilibili-subtitle.git"

或在 profile 目录执行:

pnpm add "git+https://github.com/TimYi/dsh-plugin-bilibili-subtitle.git"

本地开发

git clone https://github.com/TimYi/dsh-plugin-bilibili-subtitle.git
cd dsh-plugin-bilibili-subtitle
pnpm add "link:$PWD"

插件以 bundle 形式声明(cordis.patch.yml 插入 bilibili-subtitle 一行),装好后工具随 profile 全局可用。

使用

工具名:bilibili_subtitle

参数必填说明
url是视频链接或 BV 号,如 https://www.bilibili.com/video/BV13Axv6EEsa/
mode否auto(默认)/ official / asr
language否官方字幕语言偏好、ASR 语言标签,默认 zh

输出:

<工作区>/bilibili-subtitles/<BV>-<标题>.srt
<工作区>/bilibili-subtitles/<BV>-<标题>.txt

示例(在 DSH 会话里直接说):

用 bilibili_subtitle 提取 https://www.bilibili.com/video/BV13Axv6EEsa/

工作原理

  1. 视频信息:先调 x/web-interface/view;被风控(412)时改为解析视频页里的 __INITIAL_STATE__,所以不依赖接口是否放行。
  2. 官方字幕:x/player/wbi/v2(自动计算 wbi 签名)→ 轨道列表 → 下载轨道 JSON → SRT。 只有视频本身有字幕、且对匿名请求开放时才会命中。
  3. ASR 回退:x/player/playurl 取最高码率音轨 → PyAV 解码为 16 kHz 单声道 → 按静音切段 → SenseVoice-small(sherpa-onnx)逐段识别 → 按标点断句、按字数分配时间轴。

性能参考:83 分钟视频约 5 分钟(8 核 CPU,RTF≈0.055)。

运行环境与缓存

首次 ASR 会自动准备一次(之后复用):

路径内容
~/.cache/dsh-bilibili-subtitle/venvPython 虚拟环境(sherpa-onnx、av、numpy)
~/.cache/dsh-bilibili-subtitle/modelsSenseVoice small int8 模型(约 240 MB)
~/.cache/dsh-bilibili-subtitle/audio音轨缓存,重复提取时直接复用
  • pip 走清华镜像,模型走 hf-mirror;
  • 缓存目录不可写时自动退回 <工作区>/.bilibili-subtitle-cache/;
  • 需要 python3(≥3.10)与 python3 -m venv。

已知限制

  • 只处理单 P 视频,多 P 默认取第一 P;
  • 官方字幕需要登录态,匿名请求多数视频拿不到,所以实际多数情况走 ASR;
  • ASR 是通用中文模型,人名、专业术语(中医、法律等)会出错,需要校对; 返回结果里的 source 会标明 official 还是 asr;
  • 首次运行需联网下载依赖与模型,之后离线可用(音轨仍需联网)。

License

MIT

Badge

Listed here? Link back with this badge — paste the snippet into your repository README.

Listed on DSH Plugin badge
[![Listed on DSH Plugin](https://dsh-plugin.com/badges/listed.svg)](https://dsh-plugin.com/plugins/TimYi/dsh-plugin-bilibili-subtitle)