Skip to main content

一个简易的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/URL
  • ApiResponseError: B 站接口失败或返回异常
  • DownloadError: 下载或处理流程失败
  • FFmpegError / FFmpegNotFoundError: ffmpeg 合并阶段失败

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

oh_my_bilibili-0.1.0.tar.gz (8.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

oh_my_bilibili-0.1.0-py3-none-any.whl (12.0 kB view details)

Uploaded Python 3

File details

Details for the file oh_my_bilibili-0.1.0.tar.gz.

File metadata

  • Download URL: oh_my_bilibili-0.1.0.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

Hashes for oh_my_bilibili-0.1.0.tar.gz
Algorithm Hash digest
SHA256 728ed6443d3326461e939020211d9d411d845f20e4a01d25f433450970cae35d
MD5 267d790d5e7667be3899f260e5467440
BLAKE2b-256 6cdd50ff1941f872d1a27e00675761dbfa4625bd1ebc2e2410d2ba0aa3daa31e

See more details on using hashes here.

Provenance

The following attestation bundles were made for oh_my_bilibili-0.1.0.tar.gz:

Publisher: publish-pypi.yml on 69gg/oh-my-bilibili

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file oh_my_bilibili-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: oh_my_bilibili-0.1.0-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

Hashes for oh_my_bilibili-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ec35b9e711ba1be7f4eef35d426ac9cb94b4d038643371c8eb75a3fd21a0c3f6
MD5 a16ada1f16f906d01daeb7f79d6da738
BLAKE2b-256 933e0e6b1922b7b55c6d05fb1d6d90555ac04b7349751694e1bb65af78865f4f

See more details on using hashes here.

Provenance

The following attestation bundles were made for oh_my_bilibili-0.1.0-py3-none-any.whl:

Publisher: publish-pypi.yml on 69gg/oh-my-bilibili

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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