oh-my-bilibili
一个简洁的 Bilibili 视频信息获取与下载库。
支持输入:
BV号AV号- B 站视频 URL
b23.tv短链
支持行为:
- 只获取视频信息(标题、简介、UP、时长等)
- 下载视频到指定路径(目录或文件路径)
安装
uv sync
构建指南
# 先同步依赖
uv sync
# 构建 sdist + wheel
uv build
构建产物位于 dist/ 目录:
*.tar.gz(source distribution)*.whl(wheel)
快速开始
from oh_my_bilibili import fetch
# 1) 仅获取视频信息
info = fetch("BV1xx411c7mD", cookie="")
print(info.title)
print(info.desc)
print(info.url)
# 2) 下载到目录(自动命名文件)
result = fetch(
"https://www.bilibili.com/video/BV1xx411c7mD",
cookie="SESSDATA=...",
save_path="./downloads",
)
print(result.path)
print(result.quality_label)
API
fetch(video, save_path=None, cookie="", prefer_quality=80, timeout=30.0, overwrite=True)
- 当
save_path is None时:返回VideoInfo - 当
save_path有值时:返回DownloadResult
get_video_info(video, cookie="", timeout=30.0)
返回 VideoInfo。
download(video, save_path, cookie="", prefer_quality=80, timeout=30.0, overwrite=True)
返回 DownloadResult。
ffmpeg 依赖
Bilibili 通常返回 DASH 分离流(视频流 + 音频流),需要本地 ffmpeg 进行合并。
若未安装 ffmpeg,会抛出 FFmpegNotFoundError。
异常
InvalidVideoIdentifierError: 输入无法解析为 BV/AV/URLApiResponseError: B 站接口失败或返回异常DownloadError: 下载或处理流程失败FFmpegError/FFmpegNotFoundError: ffmpeg 合并阶段失败
Metadata
Release files for oh-my-bilibili 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| oh_my_bilibili-0.1.2.tar.gz | 8.8 kB | With provenance | Details for oh_my_bilibili-0.1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| oh_my_bilibili-0.1.2-py3-none-any.whl | Python 3 | none | any | Details for oh_my_bilibili-0.1.2-py3-none-any.whl |
Total release size: 20.8 kB
Release files / oh_my_bilibili-0.1.2.tar.gz
| Download URL | oh_my_bilibili-0.1.2.tar.gz |
|---|---|
| Size | 8.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5af2455a4579b620c12d90c792b776057a8046413ec6bac3947bd9f94158e624
|
|
BLAKE2b-256 checksum How to use checksums |
ff44c875183af3d46e06a30188560820ffadb3ce60ce790e5e2e6b81c6fc91f0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 1, 2026.
Transparency logRelease files / oh_my_bilibili-0.1.2-py3-none-any.whl
| Download URL | oh_my_bilibili-0.1.2-py3-none-any.whl |
|---|---|
| Size | 12.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
737ce1332433662866e84ea8f7085ed4dfa0f2fe0d517f25a47a300ef676fda5
|
|
BLAKE2b-256 checksum How to use checksums |
5f4f44faf3801ddbbdcbddba3b03ef2351dc207d8664a228616e06d9203c1845
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 1, 2026.
Transparency logSecurity for oh-my-bilibili 0.1.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for oh_my_bilibili-0.1.2.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 1, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.