| name | bilibili-all-in-one |
| description | 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. Supports Bilibili session cookie authentication for publishing and high-quality downloads. Requests go to official Bilibili API endpoints over HTTPS.
|
| version | 1.0.18 |
| type | code |
| implementation | python |
| interface | cli-and-api |
| runtime | python>=3.8 |
| languages | ["zh-CN","en"] |
| tags | ["bilibili","video-download","hot-trending","subtitle","danmaku","video-publish","video-player","batch-download","multi-format"] |
| author | wscats |
| license | MIT |
| homepage | https://github.com/wscats/bilibili-all-in-one |
| repository | https://github.com/wscats/bilibili-all-in-one |
| entry_point | main.py |
| required_env_vars | [] |
| optional_env_vars | ["BILIBILI_SESSDATA","BILIBILI_BILI_JCT","BILIBILI_BUVID3","BILIBILI_PERSIST"] |
| install | pip install -r requirements.txt |
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
pip install -r requirements.txt
Dependencies
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 (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
export BILIBILI_SESSDATA="your_sessdata"
export BILIBILI_BILI_JCT="your_bili_jct"
export BILIBILI_BUVID3="your_buvid3"
2. Credential File
Create a JSON file (e.g., .credentials.json):
{
"sessdata": "your_sessdata",
"bili_jct": "your_bili_jct",
"buvid3": "your_buvid3"
}
3. Direct Parameters
Pass credentials directly when initializing:
from main import BilibiliAllInOne
app = BilibiliAllInOne(
sessdata="your_sessdata",
bili_jct="your_bili_jct",
buvid3="your_buvid3",
)
4. Persistent Storage (Optional)
By default, credentials are kept in-memory only and are not saved to disk. To enable automatic persistence across sessions:
export BILIBILI_PERSIST=1
app = BilibiliAllInOne(persist=True)
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 / app.auth.persist = False
- To delete the persisted file:
app.auth.clear_persisted()
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.
5. Auto-Refresh from CDP Browser (Recommended)
When credentials expire (Bilibili sessions typically last ~30 days), use the auto-refresh script to extract fresh cookies directly from your browser via CDP โ no manual DevTools copy-paste needed.
Prerequisite: CDP Proxy must be running and your browser logged into bilibili.com.
python scripts/refresh-credentials.py
python scripts/refresh-credentials.py --check-only
python scripts/refresh-credentials.py --output /path/to/.credentials.json
python scripts/refresh-credentials.py --quiet
How it works:
- Opens bilibili.com in a background CDP tab (your browser's existing login session)
- Extracts
SESSDATA, bili_jct, buvid3 cookies via Network.getCookies (includes HttpOnly cookies)
- Saves to
.credentials.json with 0600 permissions
- Closes the background tab
When to use:
- After logging into bilibili.com in your browser
- When API calls return
-101 (credential expired)
- Proactively before running long batch operations
โ ๏ธ 2026-05-26 ๆดๆฐ๏ผ ่ฏฅ่ๆฌไพ่ต CDP Proxy ็ /cookies ็ซฏ็น๏ผNetwork.getCookies๏ผ๏ผ้่ฆ web-access skill ็ CDP Proxy ๅทฒๆดๆฐๅฐๆฏๆ่ฏฅ็ซฏ็น็็ๆฌใ
โ ๏ธ Security & Privacy
Credential Handling
This skill handles sensitive Bilibili session cookies. Please read the following carefully:
| Concern | Detail |
|---|
| What credentials are needed? | SESSDATA, 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, AI subtitle access |
| Which features work WITHOUT credentials? | Hot monitoring, standard-quality downloads, 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? | .credentials.json is auto-detected and loaded without any configuration. Use persist=True or BILIBILI_PERSIST=1 to enable runtime auto-save. You can also manually call auth.save_to_file() |
| File permissions for saved credentials | 0600 (owner read/write only) โ restrictive by default |
Best Practices
- ๐งช 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 |
|---|
api.bilibili.com | Video info, stats, hot lists, subtitles, danmaku, playback URLs |
member.bilibili.com | 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
่พๅบ็ฎๅฝ่ง่
ๆๆไบงๅบๆไปถๅฟ
้กปไฟๅญๅฐ็ปไธ็ .tmp/ ็ฎๅฝไธ๏ผๆ็ฑปๅๅๅฐๅฏนๅบๅญ็ฎๅฝ๏ผ
.tmp/bilibili-all-in-one/
โโโ video/ # mp4, flv
โโโ audio/ # mp3
โโโ subtitles/ # srt, ass, vtt
โโโ danmaku/ # ้ข็๏ผๅผนๅน
| ๆไปถ็ฑปๅ | output_dir |
|---|
| ่ง้ข (mp4/flv) | .tmp/bilibili-all-in-one/video |
| ้ณ้ข (mp3) | .tmp/bilibili-all-in-one/audio |
| ๅญๅน (srt/ass/vtt) | .tmp/bilibili-all-in-one/subtitles |
ๆชๆฅๆฐๅข็ฑปๅ๏ผๅฆ danmaku๏ผๆถๆ็
งๅๆ ทๆจกๅผๅจ .tmp/bilibili-all-in-one/ ไธๆฐๅขๅฏนๅบๅญ็ฎๅฝใ
็ฆๆญขไฝฟ็จ้กน็ฎๆ น็ฎๅฝๆๅ
ถไป่ทฏๅพไฝไธบ่พๅบ็ฎๅฝใๆฏๆฌก่ฐ็จ CLI ๆถๅฟ
้กปๆพๅผไผ ๅ
ฅ output_dir ๅๆฐใ
CLI
python main.py <skill_name> <action> [params_json]
Python API
import asyncio
from main import BilibiliAllInOne
app = BilibiliAllInOne()
async def demo():
result = await app.execute("hot_monitor", "get_hot", limit=5)
print(result)
asyncio.run(demo())
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 |
|---|
get_hot | Get popular/hot videos | page, page_size |
get_trending | 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
all, anime, music, dance, game, tech, life, food, car, fashion, entertainment, movie, tv
Examples
python main.py hot_monitor get_hot '{"page_size": 10}'
python main.py hot_monitor get_trending '{"limit": 5}'
python main.py hot_monitor get_weekly
python main.py hot_monitor get_rank '{"category": "game", "limit": 10}'
result = await app.execute("hot_monitor", "get_hot", page_size=10)
result = await app.execute("hot_monitor", "get_rank", category="game", limit=10)
2. โฌ๏ธ Downloader (bilibili_downloader)
Download Bilibili videos with support for multiple quality options, batch downloading, and format selection.
Actions
| Action | Description | Parameters |
|---|
get_info | Get video information | url |
get_formats | 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
360p, 480p, 720p, 1080p (default), 1080p+, 4k
Format Options
mp4 (default), flv, mp3 (audio only)
Examples
python main.py downloader get_info '{"url": "BV1xx411c7mD"}'
python main.py downloader get_formats '{"url": "BV1xx411c7mD"}'
python main.py downloader download '{"url": "BV1xx411c7mD", "quality": "1080p", "format": "mp4", "output_dir": ".tmp/bilibili-all-in-one/video"}'
python main.py downloader download '{"url": "BV1xx411c7mD", "format": "mp3", "output_dir": ".tmp/bilibili-all-in-one/audio"}'
python main.py downloader batch_download '{"urls": ["BV1xx411c7mD", "BV1yy411c8nE"], "quality": "720p"}'
info = await app.execute("downloader", "get_info", url="BV1xx411c7mD")
result = await app.execute("downloader", "download", url="BV1xx411c7mD", quality="1080p")
3. ๐ Watcher (bilibili_watcher)
Watch and monitor Bilibili videos. Track view counts, comments, likes, and other engagement metrics over time.
Actions
| Action | Description | Parameters |
|---|
watch | Get detailed video information | url |
get_stats | 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 BVxxxxxx
Examples
python main.py watcher watch '{"url": "BV1xx411c7mD"}'
python main.py watcher get_stats '{"url": "BV1xx411c7mD"}'
python main.py watcher track '{"url": "BV1xx411c7mD", "interval": 30, "duration": 12}'
python main.py watcher compare '{"urls": ["BV1xx411c7mD", "BV1yy411c8nE"]}'
comparison = await app.execute("watcher", "compare", urls=["BV1xx411c7mD", "BV1yy411c8nE"])
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:
- 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 |
|---|
list | List available subtitles | url |
download | 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
srt (default), ass, vtt, txt, json
Supported Languages
zh-CN (default), en, ja, and other language codes available on the video.
Fallback Strategy
When download is called and no CC subtitles exist:
CC Subtitle Available? โโYesโโโถ Download CC subtitle
โ
No
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Fallback 1: Speech Recognition โ
โ Download audio โ faster-whisper โ
โ Output: {title}_transcribed.srt โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ Fallback 2: Danmaku Extraction โ
โ Fetch bullet comments โ SRT โ
โ Output: {title}_danmaku.srt โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Examples
python main.py subtitle list '{"url": "BV1xx411c7mD"}'
python main.py subtitle download '{"url": "BV1xx411c7mD", "language": "zh-CN", "format": "srt", "output_dir": ".tmp/bilibili-all-in-one/subtitles"}'
python main.py subtitle download '{"url": "BV1xx411c7mD", "language": "en", "format": "ass", "output_dir": ".tmp/bilibili-all-in-one/subtitles"}'
python main.py subtitle convert '{"input_path": ".tmp/bilibili-all-in-one/subtitles/video.srt", "output_format": "vtt"}'
python main.py subtitle merge '{"input_paths": [".tmp/bilibili-all-in-one/subtitles/part1.srt", ".tmp/bilibili-all-in-one/subtitles/part2.srt"], "output_path": ".tmp/bilibili-all-in-one/subtitles/merged.srt"}'
subs = await app.execute("subtitle", "list", url="BV1xx411c7mD")
result = await app.execute("subtitle", "download", url="BV1xx411c7mD", language="zh-CN", format="srt")
5. โถ๏ธ Player (bilibili_player)
Play Bilibili videos with support for playback control, playlist management, and danmaku (bullet comments) display.
Actions
| Action | Description | Parameters |
|---|
play | Get complete playback info | url, quality, page |
get_playurl | 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
python main.py player play '{"url": "BV1xx411c7mD", "quality": "1080p"}'
python main.py player get_playurl '{"url": "BV1xx411c7mD", "quality": "720p"}'
python main.py player get_danmaku '{"url": "BV1xx411c7mD"}'
python main.py player get_playlist '{"url": "BV1xx411c7mD"}'
python main.py player play '{"url": "BV1xx411c7mD", "quality": "1080p", "page": 3}'
play_info = await app.execute("player", "play", url="BV1xx411c7mD", quality="1080p")
danmaku = await app.execute("player", "get_danmaku", url="BV1xx411c7mD")
playlist = await app.execute("player", "get_playlist", url="BV1xx411c7mD")
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 |
|---|
upload | Upload and publish a video | file_path, title, description, tags, category, cover_path, dynamic, no_reprint, open_elec |
draft | 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 |
|---|
file_path | string | required | Path to the video file |
title | 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
python main.py publisher upload '{"file_path": "./video.mp4", "title": "My Video", "description": "Hello World", "tags": ["test", "demo"], "category": "171"}'
python main.py publisher draft '{"file_path": "./video.mp4", "title": "Draft Video"}'
python main.py publisher schedule '{"file_path": "./video.mp4", "title": "Scheduled Video", "schedule_time": "2025-12-31T20:00:00+08:00"}'
python main.py publisher edit '{"bvid": "BV1xx411c7mD", "file_path": "./video.mp4", "title": "New Title", "tags": ["updated"]}'
app = BilibiliAllInOne(sessdata="xxx", bili_jct="xxx", buvid3="xxx")
result = await app.execute("publisher", "upload",
file_path="./video.mp4",
title="My Video",
description="Published via bilibili-all-in-one",
tags=["python", "bilibili"],
)
result = await app.execute("publisher", "edit",
bvid="BV1xx411c7mD",
file_path="./video.mp4",
title="New Title",
tags=["updated"],
)
Project Structure
bilibili-all-in-one/
โโโ skill.json # Skill configuration & parameter schema
โโโ skill.md # This documentation file
โโโ README.md # Project README (Chinese)
โโโ LICENSE # MIT License
โโโ requirements.txt # Python dependencies
โโโ .gitignore # Git ignore rules
โโโ main.py # Entry point & unified BilibiliAllInOne class
โโโ src/
โโโ __init__.py # Package exports
โโโ auth.py # Authentication & credential management
โโโ utils.py # Shared utilities, API constants, helpers
โโโ hot_monitor.py # Hot/trending video monitoring
โโโ downloader.py # Video downloading
โโโ watcher.py # Video watching & stats tracking
โโโ subtitle.py # Subtitle downloading & processing
โโโ player.py # Video playback & danmaku
โโโ publisher.py # Video uploading & publishing
Response Format
All skill actions return a JSON object with a unified structure:
{
"success": true,
"...": "action-specific fields"
}
On error:
{
"success": false,
"message": "Error description"
}
License
MIT