一个简易的Bilibili视频下载器,基于逆向接口
Project description
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 合并阶段失败
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 oh_my_bilibili-0.1.1.tar.gz.
File metadata
- Download URL: oh_my_bilibili-0.1.1.tar.gz
- Upload date:
- Size: 8.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
55788697a94c152dca3ec5f014a6015005face067753ac0d7631ecb5e9b8cb96
|
|
| MD5 |
19081186bfd33a8082e687e58e1acff0
|
|
| BLAKE2b-256 |
75b621aba0e48dc3fe3336f8bfc06ae17610ec2646b3ebad81b0e28edae5c0e2
|
Provenance
The following attestation bundles were made for oh_my_bilibili-0.1.1.tar.gz:
Publisher:
publish-pypi.yml on 69gg/oh-my-bilibili
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
oh_my_bilibili-0.1.1.tar.gz -
Subject digest:
55788697a94c152dca3ec5f014a6015005face067753ac0d7631ecb5e9b8cb96 - Sigstore transparency entry: 1006315720
- Sigstore integration time:
-
Permalink:
69gg/oh-my-bilibili@54f3ef988440c648320f6d35da6a2880f27a43bc -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/69gg
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@54f3ef988440c648320f6d35da6a2880f27a43bc -
Trigger Event:
push
-
Statement type:
File details
Details for the file oh_my_bilibili-0.1.1-py3-none-any.whl.
File metadata
- Download URL: oh_my_bilibili-0.1.1-py3-none-any.whl
- Upload date:
- Size: 12.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9c63a7b059e9dde5f7c777a8cf5799953dd131b88819cd7f10516e9c409130dc
|
|
| MD5 |
4b7a93bd60ba1f888a8911de4b0fb974
|
|
| BLAKE2b-256 |
3751ad42c12ce87722865777c4e7dae1263e447c4461053d4c33112a36f48d3c
|
Provenance
The following attestation bundles were made for oh_my_bilibili-0.1.1-py3-none-any.whl:
Publisher:
publish-pypi.yml on 69gg/oh-my-bilibili
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
oh_my_bilibili-0.1.1-py3-none-any.whl -
Subject digest:
9c63a7b059e9dde5f7c777a8cf5799953dd131b88819cd7f10516e9c409130dc - Sigstore transparency entry: 1006315722
- Sigstore integration time:
-
Permalink:
69gg/oh-my-bilibili@54f3ef988440c648320f6d35da6a2880f27a43bc -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/69gg
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@54f3ef988440c648320f6d35da6a2880f27a43bc -
Trigger Event:
push
-
Statement type: