2.3 KiB
2.3 KiB
KB Bilibili Content Skill
kb-bilibili-content - Download Bilibili videos and extract content.
Features
- Video download using yt-dlp (recommended)
- Subtitle extraction
- Article content extraction
- Multiple quality options (360P/480P/720P/1080P)
- Supports
BILIBILI_COOKIEenvironment variable
Environment Variables
| Variable | Required | Description |
|---|---|---|
BILIBILI_COOKIE |
No | B站登录 Cookie (for member-only videos) |
Commands
# Download video (720P default)
python bilibili_content.py --id "BV1xx411c7mD" --type video --output "/path/to/downloads/"
# Download video (1080P)
python bilibili_content.py --id "BV1xx411c7mD" --type video --quality 80 --output "/path/to/downloads/"
# Download video (480P)
python bilibili_content.py --id "BV1xx411c7mD" --type video --quality 32 --output "/path/to/downloads/"
# Extract subtitle
python bilibili_content.py --id "BV1xx411c7mD" --type subtitle --output "/path/to/subtitles/"
# Get article content
python bilibili_content.py --id "cv43780186" --type article --output "/path/to/article.md"
Output
{
"success": true,
"type": "video",
"filename": "video_title.mp4",
"filepath": "/path/to/downloads/video_title.mp4",
"message": "下载完成: video_title.mp4"
}
Cookie Setup
Get Cookie from Browser
- Login to bilibili.com
- Press F12 → Network → Refresh page
- Copy Cookie from request headers
Set Environment Variable
# Add to ~/.bashrc for persistence
export BILIBILI_COOKIE="SESSDATA=xxx; bili_jct=xxx; DedeUserID=xxx; DedeUserID__ckMd5=xxx"
# Or set temporarily
export BILIBILI_COOKIE="your_cookie_here"
Installation
cp -r kb-bilibili-content/ ~/skills/
pip install aiohttp playwright
playwright install chromium
How It Works
Video download uses yt-dlp with Netscape-format cookie file:
- Parses
BILIBILI_COOKIEenvironment variable - Creates temporary Netscape-format cookie file
- Runs
yt-dlp --cookies <file> -f <format> -o <output> - Cleans up temporary file
Quality Options
| Quality | ID | Resolution | Notes |
|---|---|---|---|
| 16 | 360P | 640x360 | Fastest |
| 32 | 480P | 852x480 | Default for low bandwidth |
| 64 | 720P | 1280x720 | Recommended |
| 80 | 1080P | 1920x1080 | Best quality |
Default quality: 64 (720P)