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,不需要手动执行刷新命令。

运行参数

  • --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 - 只输出,不复制到剪贴板

获取 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.2.11.tar.gz (144.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.2.11-py3-none-any.whl (25.0 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for bilibili_subtitle_fetch-0.2.11.tar.gz
Algorithm Hash digest
SHA256 321e95665a7d0ce861666842b6e5fa46147d978c2612c536e47fb5b2350d74a2
MD5 3cc75120f4463e706ca784869aac666e
BLAKE2b-256 d9364836b05b18fece01938bbac8d8a86bcd55286cea523a02d38bd002b75d00

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bilibili_subtitle_fetch-0.2.11-py3-none-any.whl
Algorithm Hash digest
SHA256 39b95cbe2d25d2aa9ca4bcd3eedcf620cef00f528b9973f3dade815e63bf6680
MD5 74e3df863a9cd02441b5603f9253e31d
BLAKE2b-256 e2ad576b8a48b8319e79b22c2681c14aba5636bc1f08baa9e5b08f52ad271dab

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