A CLI for Bilibili — browse videos, users, favorites from the terminal
Project description
bilibili-cli
A CLI for Bilibili — browse videos, users, favorites from the terminal 📺
Features
- 🎬 Video — details, subtitles, AI summary, comments, related videos
- 👤 User — profile, video list, following list
- 🔍 Search — search users or videos by keyword
- 🔥 Trending — hot videos and site-wide ranking
- 📰 Feed — dynamic timeline from your follows
- 📂 Favorites — browse favorite folders, watch-later, and watch history
- 👍 Interactions — like, coin, triple (一键三连)
- 🔐 Smart auth — auto-extracts cookies from Chrome/Firefox, or QR code login
- 📊 JSON output — major query commands support
--jsonfor scripting
Installation
# Recommended: pipx (auto-manages virtualenv)
pipx install bilibili-cli
# Or: uv tool
uv tool install bilibili-cli
Or from source:
git clone git@github.com:jackwener/bilibili-cli.git
cd bilibili-cli
uv sync
Run tests in the project environment:
uv run pytest -q
uv run ruff check .
uv run mypy bili_cli
Usage
# Login & account
bili status # Check login status
bili login # QR code login
bili whoami # Detailed profile (level, coins, followers)
# Videos
bili video BV1ABcsztEcY # Video details
bili video BV1ABcsztEcY --subtitle # With subtitles
bili video BV1ABcsztEcY --ai # AI summary
bili video BV1ABcsztEcY --comments # Top comments
bili video BV1ABcsztEcY --related # Related videos
bili video BV1ABcsztEcY --json # Raw JSON
# Users
bili user 946974 # UP profile
bili user "影视飓风" # Search by name
bili user-videos 946974 --max 20 # Video list
# Discovery
bili hot # Trending videos (page 1)
bili hot --page 2 --max 10 # Page 2, top 10
bili rank # Site-wide ranking (3-day)
bili rank --day 7 --max 30 # 7-day ranking, top 30
bili search "关键词" # Search users
bili search "关键词" --type video --max 5 # Search videos (top 5)
bili search "关键词" --page 2 # Next page
bili feed # Dynamic timeline
# Collections
bili favorites # Favorite folders
bili favorites <ID> --page 2 # Videos in a folder
bili following # Following list
bili watch-later # Watch later
bili history # Watch history
# Interactions
bili like BV1ABcsztEcY # Like
bili coin BV1ABcsztEcY # Give coin
bili triple BV1ABcsztEcY # 一键三连 🎉
Authentication
bilibili-cli uses a 3-tier authentication strategy:
- Saved credential — loads from
~/.bilibili-cli/credential.json - Browser cookies — auto-extracts from Chrome, Firefox, Edge, or Brave
- QR code login —
bili logindisplays a QR code in the terminal
Credentials are validated on use for authenticated commands. Expired cookies are automatically cleared, while transient network validation failures keep local credentials for best-effort fallback.
bili status exits with code 0 only when authenticated; otherwise it exits with 1.
Most commands work without login. Subtitles, favorites, feed, and interactions require authentication.
Use as AI Agent Skill
bilibili-cli ships with a SKILL.md that teaches AI agents how to use it.
Claude Code / Antigravity
# Clone into your project's skills directory
mkdir -p .agents/skills
git clone git@github.com:jackwener/bilibili-cli.git .agents/skills/bilibili-cli
# Or just copy the SKILL.md
curl -o .agents/skills/bilibili-cli/SKILL.md \
https://raw.githubusercontent.com/jackwener/bilibili-cli/main/SKILL.md
Once added, AI agents that support the .agents/skills/ convention will automatically discover and use bilibili-cli commands.
OpenClaw / ClawHub
Officially supports OpenClaw and ClawHub. Install via ClawHub:
clawhub install bilibili-cli
All bilibili-cli commands are available in OpenClaw after installation.
功能特性
- 🎬 视频 — 详情、字幕、AI 总结、评论、相关推荐
- 👤 用户 — UP 主资料、视频列表、关注列表
- 🔍 搜索 — 按关键词搜索用户或视频
- 🔥 发现 — 热门视频、全站排行榜
- 📰 动态 — 关注的人的动态时间线
- 📂 收藏 — 收藏夹浏览、稍后再看、观看历史
- 👍 互动 — 点赞、投币、一键三连
- 🔐 智能认证 — 自动提取浏览器 Cookie,或扫码登录
- 📊 JSON 输出 — 主要查询命令支持
--json,方便脚本调用
安装
# 推荐:pipx(自动管理虚拟环境)
pipx install bilibili-cli
# 或者:uv tool
uv tool install bilibili-cli
或从源码安装:
git clone git@github.com:jackwener/bilibili-cli.git
cd bilibili-cli
uv sync
使用示例
# 登录与账号
bili status # 检查登录状态
bili login # 扫码登录
bili whoami # 查看个人信息(等级、硬币、粉丝数)
# 视频
bili video BV1ABcsztEcY # 视频详情
bili video BV1ABcsztEcY --subtitle # 显示字幕
bili video BV1ABcsztEcY --ai # AI 总结
bili video BV1ABcsztEcY --comments # 热门评论
bili video BV1ABcsztEcY --related # 相关推荐
# 用户
bili user 946974 # UP 主资料
bili user "影视飓风" # 按用户名搜索
bili user-videos 946974 --max 20 # 视频列表
# 发现
bili hot # 热门视频(第1页)
bili hot --page 2 --max 10 # 第2页,前10条
bili rank # 全站排行榜(3日)
bili rank --day 7 --max 30 # 7日榜,前30条
bili search "关键词" # 搜索用户
bili search "关键词" --type video --max 5 # 搜索视频(前5条)
bili search "关键词" --page 2 # 第2页结果
bili feed # 动态时间线
# 收藏
bili favorites # 收藏夹列表
bili following # 关注列表
bili watch-later # 稍后再看
bili history # 观看历史
# 互动
bili like BV1ABcsztEcY # 点赞
bili coin BV1ABcsztEcY # 投币
bili triple BV1ABcsztEcY # 一键三连 🎉
认证策略
bilibili-cli 采用三级认证策略:
- 已保存凭证 — 从
~/.bilibili-cli/credential.json加载 - 浏览器 Cookie — 自动从 Chrome、Firefox、Edge、Brave 提取
- 扫码登录 —
bili login在终端显示二维码
需要认证的命令会自动校验凭证。过期 Cookie 会自动清除;如果只是临时网络异常,不会误清本地凭证(会以 best-effort 继续尝试)。
大部分命令无需登录。字幕、收藏夹、动态和互动操作需要登录。
作为 AI Agent Skill 使用
bilibili-cli 自带 SKILL.md,让 AI Agent 能自动学习并使用本工具。
Claude Code / Antigravity
# 克隆到项目的 skills 目录
mkdir -p .agents/skills
git clone git@github.com:jackwener/bilibili-cli.git .agents/skills/bilibili-cli
# 或者只复制 SKILL.md
curl -o .agents/skills/bilibili-cli/SKILL.md \
https://raw.githubusercontent.com/jackwener/bilibili-cli/main/SKILL.md
添加后,支持 .agents/skills/ 的 AI Agent 会自动发现并使用 bilibili-cli 命令。
OpenClaw / ClawHub
官方支持 OpenClaw 和 ClawHub 生态。通过 ClawHub 安装:
clawhub install bilibili-cli
安装后即可在 OpenClaw 中直接使用所有 bilibili-cli 命令。
License
Apache-2.0
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 bilibili_cli-0.2.0.tar.gz.
File metadata
- Download URL: bilibili_cli-0.2.0.tar.gz
- Upload date:
- Size: 155.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a5c4b350f5c46a570aa55103d2330546af33bd9c077151f3287abe81827aefc5
|
|
| MD5 |
062283f780e9e55a60389e33cf015be0
|
|
| BLAKE2b-256 |
dc6553e917fa4f762d932b12f9da5aab0e19e4b679d534543db14695638beee1
|
Provenance
The following attestation bundles were made for bilibili_cli-0.2.0.tar.gz:
Publisher:
publish.yml on jackwener/bilibili-cli
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
bilibili_cli-0.2.0.tar.gz -
Subject digest:
a5c4b350f5c46a570aa55103d2330546af33bd9c077151f3287abe81827aefc5 - Sigstore transparency entry: 1029140910
- Sigstore integration time:
-
Permalink:
jackwener/bilibili-cli@4bba0452f57c7bc18825c91d7d419ff377bafe44 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/jackwener
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@4bba0452f57c7bc18825c91d7d419ff377bafe44 -
Trigger Event:
release
-
Statement type:
File details
Details for the file bilibili_cli-0.2.0-py3-none-any.whl.
File metadata
- Download URL: bilibili_cli-0.2.0-py3-none-any.whl
- Upload date:
- Size: 28.7 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 |
c93d915682001a935973bd04bc98527fef3dae4afd0706a0d4d3443e3eb23bf0
|
|
| MD5 |
67fb05a5758399dff61b9ab24ef216be
|
|
| BLAKE2b-256 |
a4615a1ebd63b0638609586f2fe40a467545d92987a3ea1d1a05dd05f9fcfe03
|
Provenance
The following attestation bundles were made for bilibili_cli-0.2.0-py3-none-any.whl:
Publisher:
publish.yml on jackwener/bilibili-cli
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
bilibili_cli-0.2.0-py3-none-any.whl -
Subject digest:
c93d915682001a935973bd04bc98527fef3dae4afd0706a0d4d3443e3eb23bf0 - Sigstore transparency entry: 1029141183
- Sigstore integration time:
-
Permalink:
jackwener/bilibili-cli@4bba0452f57c7bc18825c91d7d419ff377bafe44 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/jackwener
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@4bba0452f57c7bc18825c91d7d419ff377bafe44 -
Trigger Event:
release
-
Statement type: