A CLI tool to capture subtitles from video sites (Bilibili, etc.)
Project description
项目结构
SubtitleCapturer/ ├── pyproject.toml # PEP 621 打包配置 ├── requirements.txt # 仅 httpx ├── src/subtitle_capturer/ │ ├── cli.py # argparse CLI + 输出写入 + 交互式语言选择 │ ├── models.py # SubtitleInterval, SubtitleTrack, VideoInfo, FetchResult │ ├── exceptions.py # 8 种自定义异常,每种带 exit_code │ └── platforms/ │ ├── base.py # BasePlatform 抽象基类 + SRT 转换工具 │ └── bilibili/ │ ├── constants.py # API URLs, Headers, WBI 置换表, URL 正则 │ ├── wbi.py # WBI 签名算法(已通过已知测试向量验证) │ ├── api.py # BilibiliApiClient(含 WBI 签名、错误处理) │ └── platform.py # BilibiliPlatform 完整实现 ├── tests/ # 11 个测试,全部通过 └── output/ # 默认输出目录
使用方式
基本用法(会交互式选择字幕轨道)
subcap BV1xx411c7mD --cookie "你的SESSDATA值"
完整 URL + 指定语言 + 自定义输出目录
subcap "https://www.bilibili.com/video/BV1xx411c7mD" -l zh-CN -o ./subs --cookie xxx
下载所有字幕轨道
subcap BV1xx411c7mD -l all --cookie xxx
仅输出 JSON
subcap BV1xx411c7mD --no-srt --cookie xxx
获取 Cookie 从浏览器 DevTools → Application → Cookies → bilibili.com,复制 SESSDATA 的值。也可以通过环境变量 BILIBILI_SESSDATA 或 --cookie 参数传入文件路径。
扩展新平台 只需在 platforms/ 下新建子包,继承 BasePlatform 实现 fetch() 和 get_track_list(),然后在 platforms/init.py 中 register() 即可。
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file subtitle_capturer-0.1.0.tar.gz.
File metadata
- Download URL: subtitle_capturer-0.1.0.tar.gz
- Upload date:
- Size: 12.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cca1090e9ce12e82fe95f42f36663211ec7b000335c7b4d09011f7b71970311c
|
|
| MD5 |
0c09e398897a8bb1d432ae512bbe7c5a
|
|
| BLAKE2b-256 |
dc7a8e408df9acfe42c63ecad65e95671c2cdec8001749d369d01fe61da6f2ad
|
File details
Details for the file subtitle_capturer-0.1.0-py3-none-any.whl.
File metadata
- Download URL: subtitle_capturer-0.1.0-py3-none-any.whl
- Upload date:
- Size: 12.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3f2e034395d1ddd41ef53e920a02d8d90f5028a62f1adcc9a33d57faa282b272
|
|
| MD5 |
574b35ec7310455b1f3d9763377ce9b5
|
|
| BLAKE2b-256 |
ebf46d7d7997b962c549cf0f8b33dbdf5f9731947fee8361a14934c082c26160
|