Bilibili All-in-One Skill
A comprehensive Bilibili toolkit that integrates hot trending monitoring, video downloading, video watching/playback, subtitle downloading, and video publishing capabilities into a single unified skill.
⚠️ Optional Environment Variables: BILIBILI_SESSDATA, BILIBILI_BILI_JCT (optional), BILIBILI_BUVID3 (optional), BILIBILI_PERSIST (optional)
These are sensitive Bilibili session cookies needed only for publishing and high-quality (1080p+/4K) downloads.
Most features work WITHOUT any credentials: hot monitoring, standard-quality downloads, subtitle listing, danmaku, stats viewing.
📦 Install: pip install -r requirements.txt (all standard PyPI packages: httpx, aiohttp, beautifulsoup4, lxml, requests)
🔗 Source: github.com/wscats/bilibili-all-in-one
何时激活
当用户明确请求以下 Bilibili 相关操作时,本 Skill 可被激活:
| 触发场景 | 匹配的模块 | 典型触发词 |
|---|
| 查看B站热门、热搜、排行榜、必看榜 | 🔥 Hot Monitor | "热门"、"热搜"、"排行"、"趋势"、"必看"、"流行"、"榜单" |
| 下载B站视频、提取音频、批量下载 |
⬇️ Downloader | "下载"、"保存视频"、"提取音频"、"导出MP4"、"批量下载" |
| 查看视频播放量、点赞数、数据追踪、对比 | 👀 Watcher | "播放量"、"点赞"、"数据"、"统计"、"对比"、"监控"、"追踪"、"观看量" |
| 下载字幕、转换字幕格式、合并字幕 | 📝 Subtitle | "字幕"、"CC"、"SRT"、"ASS"、"字幕下载"、"字幕转换"、"翻译" |
| 播放视频、获取弹幕、播放列表 | ▶️ Player | "播放"、"弹幕"、"播放地址"、"分P"、"播放列表"、"danmaku" |
| 上传视频、发布、定时发布、草稿、编辑 | 📤 Publisher | "上传"、"发布"、"投稿"、"定时发布"、"草稿"、"编辑视频" |
⚠️ 注意:本 Skill 不会仅因消息中出现 Bilibili 链接或 BV 号就自动激活。只有当用户明确表达了操作意图(如"下载这个视频"、"查看热门"等)时才会被调用。涉及写操作(发布/编辑)时,需要用户显式提供凭证。
Features
| Module | Description |
|---|
| 🔥 Hot Monitor | Monitor Bilibili hot/trending videos and topics in real-time |
| ⬇️ Downloader |
Download Bilibili videos with multiple quality and format options |
| 👀
Watcher | Watch and track video engagement metrics (supports Bilibili) |
| 📝
Subtitle | Download and process subtitles in multiple formats and languages |
| ▶️
Player | Get playback URLs, danmaku (bullet comments), and playlist info |
| 📤
Publisher | Upload, schedule, edit, and manage videos on Bilibili |
Installation
Requirements
- - Python >= 3.8
- ffmpeg (optional, for merging video/audio streams)
Install Dependencies
CODEBLOCK0
Dependencies
- - INLINECODE5
- INLINECODE6
- INLINECODE7
- INLINECODE8
- INLINECODE9
- INLINECODE10 (optional, for speech recognition subtitle fallback)
Configuration
Some features (downloading high-quality videos, publishing, etc.) require Bilibili authentication. You can provide credentials in three ways:
1. Environment Variables
CODEBLOCK1
2. Credential File
Create a JSON file (e.g., credentials.json):
CODEBLOCK2
3. Direct Parameters
Pass credentials directly when initializing:
CODEBLOCK3
4. Persistent Storage (Optional)
By default, credentials are kept in-memory only and are not saved to disk. To enable automatic persistence across sessions:
CODEBLOCK4
CODEBLOCK5
When persistence is enabled:
- - Credentials are auto-saved to
.credentials.json (with 0600 permissions) after initialization - On next startup, credentials are auto-loaded from this file
- You can toggle persistence at runtime:
app.auth.persist = True / INLINECODE15 - To delete the persisted file: INLINECODE16
How to get cookies: Log in to bilibili.com, open browser DevTools (F12) → Application → Cookies, and copy the values of SESSDATA, bili_jct, and buvid3.
⚠️ Security & Privacy
Credential Handling
This skill handles sensitive Bilibili session cookies. Please read the following carefully:
| Concern | Detail |
|---|
| What credentials are needed? | INLINECODE20 , bili_jct, buvid3 — Bilibili full browser session cookies (not limited API keys). Providing them grants broad access to your Bilibili account. |
| Which features require authentication? |
Publishing (upload/edit/schedule/draft), downloading 1080p+/4K quality videos |
|
Which features work WITHOUT credentials? | Hot monitoring, standard-quality downloads, subtitle listing, danmaku fetching, stats viewing |
|
Where are credentials sent? | To official Bilibili API endpoints (
api.bilibili.com,
member.bilibili.com) over HTTPS only |
|
Are credentials persisted to disk? |
NO by default — credentials stay in memory. Set
persist=True or
BILIBILI_PERSIST=1 to opt-in to automatic persistence (saved to
.credentials.json with
0600 permissions). You can also manually call
auth.save_to_file() |
|
File permissions for saved credentials |
0600 (owner read/write only) — restrictive by default |
Best Practices
- 1. 🧪 Use a test account — Do NOT provide your primary Bilibili account cookies for evaluation/testing purposes. These are full session cookies that grant broad account access (not limited API keys).
- 🔒 Prefer in-memory credentials — Pass credentials via environment variables or direct parameters rather than saving to a file. Only enable
persist=True if you need credentials to survive across sessions. - 📁 If you enable persistence — Credentials are saved with
0600 permissions. Use auth.clear_persisted() or auth.persist = False to remove the file when no longer needed. - 🐳 Run in isolation — When possible, run this skill in an isolated container/environment and inspect network traffic.
- 🌐 Verify network traffic — All HTTP requests go to Bilibili's official domains only. You can verify by monitoring outbound connections.
- ❌ No exfiltration — This skill does NOT send credentials to any third-party service, analytics endpoint, or telemetry server.
- 🔑 Credential scope —
SESSDATA and bili_jct are full session cookies. They are NOT scoped/limited API keys. Treat them with the same care as your account password.
Network Endpoints Used
| Domain | Purpose |
|---|
| INLINECODE37 | Video info, stats, hot lists, subtitles, danmaku, playback URLs |
| INLINECODE38 |
Video publishing (upload, edit) |
|
upos-sz-upcdnbda2.bilivideo.com | Video file upload CDN |
|
www.bilibili.com | Web page scraping fallback |
Credential Requirement by Module
| Module | Auth Required? | Notes |
|---|
| 🔥 Hot Monitor | ❌ No | All public APIs |
| ⬇️ Downloader |
⚠️ Optional | Required only for 1080p+ / 4K quality |
| 👀 Watcher | ❌ No | Public stats APIs |
| 📝 Subtitle | ❌ No | Public subtitle APIs |
| ▶️ Player | ⚠️ Optional | Required for high-quality playback URLs |
| 📤 Publisher | ✅
Required | All operations need
SESSDATA +
bili_jct |
Usage
CLI
CODEBLOCK6
Python API
CODEBLOCK7
Skills Reference
1. 🔥 Hot Monitor (bilibili_hot_monitor)
Monitor Bilibili hot/trending videos and topics in real-time. Supports filtering by category, tracking rank changes.
Actions
| Action | Description | Parameters |
|---|
| INLINECODE44 | Get popular/hot videos | INLINECODE45 , INLINECODE46 |
| INLINECODE47 |
Get trending series/topics |
limit |
|
get_weekly | Get weekly must-watch list |
number (week number, optional) |
|
get_rank | Get category ranking videos |
category,
limit |
Supported Categories
INLINECODE54 , anime, music, dance, game, tech, life, food, car, fashion, entertainment, movie, INLINECODE66
Examples
CODEBLOCK8
CODEBLOCK9
2. ⬇️ Downloader (bilibili_downloader)
Download Bilibili videos with support for multiple quality options, batch downloading, and format selection.
Actions
| Action | Description | Parameters |
|---|
| INLINECODE68 | Get video information | INLINECODE69 |
| INLINECODE70 |
List available qualities/formats |
url |
|
download | Download a single video |
url,
quality,
output_dir,
format,
page |
|
batch_download | Download multiple videos |
urls,
quality,
output_dir,
format |
Quality Options
INLINECODE83 , 480p, 720p, 1080p (default), 1080p+, INLINECODE88
Format Options
INLINECODE89 (default), flv, mp3 (audio only)
Examples
CODEBLOCK10
CODEBLOCK11
3. 👀 Watcher (bilibili_watcher)
Watch and monitor Bilibili videos. Track view counts, comments, likes, and other engagement metrics over time.
Actions
| Action | Description | Parameters |
|---|
| INLINECODE93 | Get detailed video information | INLINECODE94 |
| INLINECODE95 |
Get current engagement statistics |
url |
|
track | Track metrics over time |
url,
interval (minutes),
duration (hours) |
|
compare | Compare multiple videos |
urls |
Supported Platforms
- - Bilibili:
https://www.bilibili.com/video/BVxxxxxx or INLINECODE104
Examples
CODEBLOCK12
CODEBLOCK13
4. 📝 Subtitle (bilibili_subtitle)
Download and process subtitles/CC from Bilibili videos. Supports multiple subtitle formats and languages.
When no CC subtitles are available, the module automatically falls back to:
- 1. Speech Recognition — Downloads the video's audio and transcribes it using
faster-whisper (requires pip install faster-whisper) - Danmaku Extraction — Fetches bullet comments from the video as a text reference
Both fallback results are returned together when triggered.
Actions
| Action | Description | Parameters |
|---|
| INLINECODE108 | List available subtitles | INLINECODE109 |
| INLINECODE110 |
Download subtitles (with auto-fallback) |
url,
language,
format,
output_dir |
|
convert | Convert subtitle format |
input_path,
output_format,
output_dir |
|
merge | Merge multiple subtitle files |
input_paths,
output_path,
output_format |
Supported Formats
INLINECODE123 (default), ass, vtt, txt, INLINECODE127
Supported Languages
INLINECODE128 (default), en, ja, and other language codes available on the video.
Fallback Strategy
When download is called and no CC subtitles exist:
CODEBLOCK14
Examples
CODEBLOCK15
CODEBLOCK16
5. ▶️ Player (bilibili_player)
Play Bilibili videos with support for playback control, playlist management, and danmaku (bullet comments) display.
Actions
| Action | Description | Parameters |
|---|
| INLINECODE133 | Get complete playback info | INLINECODE134 , quality, INLINECODE136 |
| INLINECODE137 |
Get direct play URLs |
url,
quality,
page |
|
get_danmaku | Get danmaku/bullet comments |
url,
page,
segment |
|
get_playlist | Get playlist/multi-part info |
url |
Danmaku Modes
| Mode | Description |
|---|
| 1 | Scroll (right to left) |
| 4 |
Bottom fixed |
| 5 | Top fixed |
Examples
CODEBLOCK17
CODEBLOCK18
6. 📤 Publisher (bilibili_publisher)
Publish videos to Bilibili. Supports uploading videos, setting metadata, scheduling publications, and managing drafts.
⚠️ Authentication Required: All publisher actions require valid Bilibili credentials.
Actions
| Action | Description | Parameters |
|---|
| INLINECODE148 | Upload and publish a video | INLINECODE149 , title, description, tags, category, cover_path, dynamic, no_reprint, INLINECODE157 |
| INLINECODE158 |
Save as draft |
file_path,
title,
description,
tags,
category,
cover_path |
|
schedule | Schedule future publication |
file_path,
title,
schedule_time,
description,
tags,
category,
cover_path |
|
edit | Edit existing video metadata |
bvid,
file_path,
title,
description,
tags,
cover_path |
Upload Parameters
| Parameter | Type | Default | Description |
|---|
| INLINECODE180 | string | required | Path to the video file |
| INLINECODE181 |
string |
required | Video title (max 80 chars) |
|
description | string |
"" | Video description (max 2000 chars) |
|
tags | string[] |
["bilibili"] | Tags (max 12, each max 20 chars) |
|
category | string |
"171" | Category TID |
|
cover_path | string |
null | Path to cover image (JPG/PNG) |
|
no_reprint | int |
1 | 1 = original content, 0 = repost |
|
open_elec | int |
0 | 1 = enable charging, 0 = disable |
Examples
CODEBLOCK19
CODEBLOCK20
Project Structure
CODEBLOCK21
Response Format
All skill actions return a JSON object with a unified structure:
CODEBLOCK22
On error:
CODEBLOCK23
License
MIT
技能名称: bilibili-all-in-one
详细描述:
Bilibili 全能工具包
一个集热门趋势监控、视频下载、视频观看/播放、字幕下载和视频发布功能于一体的综合性 Bilibili 工具包。
⚠️ 可选环境变量: BILIBILISESSDATA, BILIBILIBILIJCT (可选), BILIBILIBUVID3 (可选), BILIBILI_PERSIST (可选)
这些是敏感的 Bilibili 会话 Cookie,仅在发布和高清(1080p+/4K)下载时需要。
大多数功能无需任何凭证即可使用: 热门监控、标准质量下载、字幕列表、弹幕、数据查看。
📦 安装: pip install -r requirements.txt(所有标准 PyPI 包:httpx, aiohttp, beautifulsoup4, lxml, requests)
🔗 源码: github.com/wscats/bilibili-all-in-one
何时激活
当用户明确请求以下 Bilibili 相关操作时,本技能可被激活:
| 触发场景 | 匹配的模块 | 典型触发词 |
|---|
| 查看B站热门、热搜、排行榜、必看榜 | 🔥 热门监控 | 热门、热搜、排行、趋势、必看、流行、榜单 |
| 下载B站视频、提取音频、批量下载 |
⬇️ 下载器 | 下载、保存视频、提取音频、导出MP4、批量下载 |
| 查看视频播放量、点赞数、数据追踪、对比 | 👀 观察者 | 播放量、点赞、数据、统计、对比、监控、追踪、观看量 |
| 下载字幕、转换字幕格式、合并字幕 | 📝 字幕 | 字幕、CC、SRT、ASS、字幕下载、字幕转换、翻译 |
| 播放视频、获取弹幕、播放列表 | ▶️ 播放器 | 播放、弹幕、播放地址、分P、播放列表、danmaku |
| 上传视频、发布、定时发布、草稿、编辑 | 📤 发布器 | 上传、发布、投稿、定时发布、草稿、编辑视频 |
⚠️ 注意:本技能不会仅因消息中出现 Bilibili 链接或 BV 号就自动激活。只有当用户明确表达了操作意图(如下载这个视频、查看热门等)时才会被调用。涉及写操作(发布/编辑)时,需要用户显式提供凭证。
功能特性
| 模块 | 描述 |
|---|
| 🔥 热门监控 | 实时监控 Bilibili 热门/趋势视频和话题 |
| ⬇️ 下载器 |
下载 Bilibili 视频,支持多种质量和格式选项 |
| 👀
观察者 | 观看和追踪视频互动指标(支持 Bilibili) |
| 📝
字幕 | 下载和处理多种格式和语言的字幕 |
| ▶️
播放器 | 获取播放地址、弹幕(弹幕评论)和播放列表信息 |
| 📤
发布器 | 在 Bilibili 上上传、定时发布、编辑和管理视频 |
安装
系统要求
- - Python >= 3.8
- ffmpeg(可选,用于合并视频/音频流)
安装依赖
bash
pip install -r requirements.txt
依赖项
- - httpx >= 0.24.0
- aiohttp >= 3.8.0
- beautifulsoup4 >= 4.12.0
- lxml >= 4.9.0
- requests >= 2.31.0
- faster-whisper >= 1.0.0 (可选,用于语音识别字幕回退)
配置
某些功能(下载高质量视频、发布等)需要 Bilibili 身份验证。您可以通过三种方式提供凭证:
1. 环境变量
bash
export BILIBILISESSDATA=yoursessdata
export BILIBILIBILIJCT=yourbilijct
export BILIBILIBUVID3=yourbuvid3
2. 凭证文件
创建一个 JSON 文件(例如 credentials.json):
json
{
sessdata: your_sessdata,
bilijct: yourbili_jct,
buvid3: your_buvid3
}
3. 直接参数
初始化时直接传递凭证:
python
from main import BilibiliAllInOne
app = BilibiliAllInOne(
sessdata=your_sessdata,
bilijct=yourbili_jct,
buvid3=your_buvid3,
)
4. 持久化存储(可选)
默认情况下,凭证仅保存在内存中,不会保存到磁盘。要启用跨会话的自动持久化:
bash
通过环境变量
export BILIBILI_PERSIST=1
python
或通过代码
app = BilibiliAllInOne(persist=True)
启用持久化后:
- - 初始化后,凭证会自动保存到 .credentials.json(权限为 0600)
- 下次启动时,凭证会自动从该文件加载
- 您可以在运行时切换持久化:app.auth.persist = True / app.auth.persist = False
- 要删除持久化文件:app.auth.clear_persisted()
如何获取 Cookie: 登录 bilibili.com,打开浏览器开发者工具(F12)→ 应用程序 → Cookie,然后复制 SESSDATA、bilijct 和 buvid3 的值。
⚠️ 安全与隐私
凭证处理
本技能处理敏感的 Bilibili 会话 Cookie。请仔细阅读以下内容:
| 关注点 | 详情 |
|---|
| 需要什么凭证? | SESSDATA、bili_jct、buvid3 — Bilibili 完整浏览器会话 Cookie(非受限 API 密钥)。提供它们将授予对您 Bilibili 账户的广泛访问权限。 |
| 哪些功能需要身份验证? |
发布(上传/编辑/定时发布/草稿)、下载 1080p+/4K 质量视频 |
|
哪些功能无需凭证即可使用? | 热门监控、标准质量下载、字幕列表、弹幕获取、数据查看 |
|
凭证发送到哪里? | 仅通过 HTTPS 发送到官方 Bilibili API 端点(api.bilibili.com、member.bilibili.com) |
|
凭证是否持久化到磁盘? | 默认
不持久化 — 凭证保留在内存中。设置 persist=True 或 BILIBILI
PERSIST=1 以选择加入自动持久化(保存到 .credentials.json,权限为 0600)。您也可以手动调用 auth.saveto_file() |
|
已保存凭证的文件权限 | 0600(仅所有者读/写)— 默认限制严格 |
最佳实践
- 1. 🧪 使用测试账户 — 请勿为评估/测试目的提供您的主 Bilibili 账户 Cookie。这些是完整的会话 Cookie,可授予广泛的账户访问权限(非受限 API 密钥)。
- 🔒 优先使用内存凭证 — 通过环境变量或直接参数传递凭证,而不是保存到文件。仅当您需要凭证跨会话持久化时,才启用 persist=True。
- 📁 如果启用持久化 — 凭证以 0600 权限保存。不再需要时,使用 auth.clearpersisted() 或 auth.persist = False 删除文件。
- 🐳 隔离运行 — 尽可能在隔离的容器/环境中运行此技能,并检查网络流量。
- 🌐 验证网络流量 — 所有 HTTP 请求仅发送到 Bilibili 的官方域名。您可以通过监控出站连接进行验证。
- ❌ 无数据泄露 — 本技能不会将凭证发送到任何第三方服务、分析端点或遥测服务器。
- 🔑 凭证范围 — SESSDATA 和 bilijct 是完整的会话 Cookie。它们不是受限/限定的 API 密钥。请像对待您的账户密码一样谨慎对待它们。
使用的网络端点
视频信息、数据、热门列表、字幕、弹幕、