Skip to main content

An MCP (Model Context Protocol) server that allows you to fetch subtitles for Bilibili videos.

Project description

Bilibili Subtitle Fetch

一个用于获取 Bilibili 视频字幕的 MCP Server,支持语言和输出格式选项。

uv tool install --python 3.13 bilibili-subtitle-fetch

支持以下输入:

  • BV 号,例如 BV1fz4y1j7Mf
  • 标准视频链接,例如 https://www.bilibili.com/video/BV1fz4y1j7Mf?p=2
  • 短链,例如 https://b23.tv/FAm7Xn4

配置

凭据配置文件

首次使用时执行 bilibili-subtitle-fetch init,然后粘贴你的 Bilibili Cookie。

默认配置文件路径:

  • Windows: %APPDATA%\bilibili-subtitle-fetch\config.toml
  • Linux/macOS: ~/.config/bilibili-subtitle-fetch/config.toml

也可以通过 --config /path/to/config.toml 指定自定义路径。

配置文件会在 [credential] 下保存这些字段:

  • sessdata - 访问需要登录态的字幕接口时必需
  • bili_jct - 自动刷新时必需
  • ac_time_value - 自动刷新时必需
  • buvid3buvid4dedeuserid - 可选,但建议一并保存

sessdatabili_jctac_time_value 都存在时,服务会在发起需要登录态的请求前自动检查是否需要刷新 Cookie,并将新值回写到 config.toml,不需要手动执行刷新命令。

ASR 配置 (可选)

配置文件同样支持 [asr] 段落配置默认的音频转写行为:

  • enable_asr - 是否开启 ASR 回退 (true/false)。开启后,如果视频未提供自带字幕,程序会自动下载音频并生成字幕。
  • model_size - Whisper 模型大小,默认为 base。也可以选用 tinysmall 等。

运行参数

  • --preferred-lang - 覆盖默认字幕语言
  • --output-format - 覆盖默认输出格式
  • --config - 使用自定义配置文件路径

CLI 用法

先执行 bilibili-subtitle-fetch init 配置 Cookie,然后可以直接在终端获取字幕:

bilibili-subtitle-fetch fetch BV1fz4y1j7Mf
bilibili-subtitle-fetch fetch "https://www.bilibili.com/video/BV1fz4y1j7Mf?p=2"

命令会把字幕输出到标准输出,并在成功后自动复制到剪贴板。

可选参数:

  • --preferred-lang - 指定优先字幕语言
  • --output-format text|timestamped - 指定输出格式
  • --no-clipboard - 只输出,不复制到剪贴板
  • --asr - 强制启用 ASR 语音识别回退
  • --no-asr - 强制关闭 ASR 语音识别回退

获取 Bilibili 凭据

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bilibili_subtitle_fetch-0.3.2.tar.gz (146.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bilibili_subtitle_fetch-0.3.2-py3-none-any.whl (26.5 kB view details)

Uploaded Python 3

File details

Details for the file bilibili_subtitle_fetch-0.3.2.tar.gz.

File metadata

  • Download URL: bilibili_subtitle_fetch-0.3.2.tar.gz
  • Upload date:
  • Size: 146.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for bilibili_subtitle_fetch-0.3.2.tar.gz
Algorithm Hash digest
SHA256 5742eb6dbbd5f52f5f5b4ffdad26c09ac99c379192cf205f585285c06cc07298
MD5 a9c0c44b8cc04df65fd19c4467b72a18
BLAKE2b-256 fde231d6d40abeae58cca2a0c52b28ad15a40cfab0bbd86ff00b88ca4396e641

See more details on using hashes here.

File details

Details for the file bilibili_subtitle_fetch-0.3.2-py3-none-any.whl.

File metadata

  • Download URL: bilibili_subtitle_fetch-0.3.2-py3-none-any.whl
  • Upload date:
  • Size: 26.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for bilibili_subtitle_fetch-0.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 bd932237e4405d3a05fcd0d9ca853c74eb472dd0a5ee1ab88a5bce6e23a6cea3
MD5 bfff2260f91214e4c9646a1c71076404
BLAKE2b-256 defae27b65889e8376e525448fdb445f1a67e4c47b6b6a92b8f8e13bd8b724b0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page