Metadata-Version: 2.4
Name: subtitle-capturer
Version: 0.1.0
Summary: A CLI tool to capture subtitles from video sites (Bilibili, etc.)
Author-email: JiD_Wang <wjd3306@163.com>
License-Expression: MIT
Project-URL: Homepage, https://github.com/lomenKiD/SubtitleCapturer
Project-URL: Repository, https://github.com/lomenKiD/SubtitleCapturer
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Console
Classifier: Intended Audience :: End Users/Desktop
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Multimedia :: Video
Classifier: Topic :: Internet :: WWW/HTTP
Classifier: Topic :: Utilities
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: httpx>=0.27.0
Dynamic: license-file

# 项目结构

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() 即可。
