video-download
0
总安装量
5
周安装量
安装命令
npx skills add https://github.com/csfuwwc/md-skills --skill video-download
Agent 安装分布
claude-code
5
opencode
4
cursor
3
replit
2
codex
2
Skill 文档
Video Download Skill
Overview
This skill enables automated video downloads from Chinese video platforms using headless browser automation. It handles platform detection, login management, and video extraction with proper quality settings.
Quick Start
When a user requests video download, follow this decision tree:
-
Identify platform from URL
- Douyin:
v.douyin.com/xxx,douyin.com/video/xxx - Xiaohongshu:
xiaohongshu.com/discovery/item/xxx,xhslink.com/xxx - Bilibili:
bilibili.com/video/BVxxx,b23.tv/xxx
- Douyin:
-
Check dependencies
- First time use â Run
scripts/install_deps.shto install playwright and ffmpeg - Dependencies verified â Proceed to platform-specific workflow
- First time use â Run
-
Execute platform workflow
- Douyin/Xiaohongshu â Direct download using
scripts/download.py - Bilibili â Check login status first, then download
- Douyin/Xiaohongshu â Direct download using
Core Capabilities
1. Platform Support
- Douyin (æé³): No login required, captures video URL from network requests
- Xiaohongshu (å°çº¢ä¹¦): No login required, captures video URL from network requests
- Bilibili (Bç«): Login recommended for HD quality, requires ffmpeg for video merging
2. Dependency Management
- Auto-installation:
scripts/install_deps.shhandles all dependencies with China mirror optimization - Dependencies: playwright (browser automation), ffmpeg (video processing for Bilibili)
- Detection: Script automatically checks for missing dependencies
3. Login Management
- Cookie persistence: Saves login state in
~/.config/video-download/<platform>_cookies.json - Interactive login: Opens visible browser for user authentication
- Status checking: Verifies login state before download
- Supported platforms: bilibili, douyin, xiaohongshu
4. Video Download
- Automatic quality: Best available quality (Bilibili HD requires login)
- Title extraction: Auto-generates filename from video title
- Output location:
~/Downloads/directory - Format: MP4 with proper codec settings
Workflow Examples
Example 1: Douyin/Xiaohongshu Direct Download
User request: “ä¸è½½è¿ä¸ªæé³è§é¢ [v.douyin.com/xxx]”
Workflow:
- Check dependencies installed using Shell command exit code
- If missing â Execute
scripts/install_deps.sh(block_until_ms: 120000) - Run
scripts/download.pywith video URL - Wait for download completion and report saved file path
Example 2: Bilibili with Login Flow
User request: “ä¸è½½è¿ä¸ªBç«è§é¢ [bilibili.com/video/BVxxx]”
Workflow:
- Check dependencies (playwright, ffmpeg)
- Check login status using
scripts/download.py check-login bilibili - If exit code 2 (LOGIN_REQUIRED):
- Launch
scripts/download.py login bilibili --signal-file /tmp/video_dl_login_done(block_until_ms: 0, run in background) - Immediately show AskQuestion to user:
- Prompt: “å·²æå¼ Bç« ç»å½é¡µé¢ï¼è¯·å¨æµè§å¨ä¸å®æç»å½ï¼å®æåç¹å»ä¸æ¹ç¡®è®¤æé®ã”
- Option A: “已宿ç»å½”
- Option B: “è·³è¿ç»å½ï¼ä½¿ç¨ä½ç»è´¨ï¼”
- If option A: Create signal file
touch /tmp/video_dl_login_done, wait for login script exit - If option B: Kill login script process, proceed with low quality
- Launch
- Run
scripts/download.pywith video URL - Report completion and file location
Example 3: First-Time User Setup
User request: “帮æä¸è½½å°çº¢ä¹¦è§é¢ [xhslink.com/xxx]”
Workflow:
- Detect first use (no playwright/ffmpeg installed)
- Inform user: “馿¬¡ä½¿ç¨éè¦å®è£ ä¾èµï¼playwright å ffmpegï¼ï¼çº¦é 1-2 åé”
- Execute
scripts/install_deps.sh(block_until_ms: 120000) - Monitor installation progress by reading terminal output
- After success, proceed with download workflow
Resource Guide
scripts/
Core script:
download.py– Main entry point for all download operations
Available commands:
- Download: Pass video URL as first argument, optional output filename as second
- Login:
login <platform>– Opens browser for authentication - Login with signal:
login <platform> --signal-file <path>– For agent interaction mode - Check status:
check-login <platform>– Returns exit code 0 (logged in) or 2 (login required)
Dependency installer:
install_deps.sh– One-click setup with China mirror optimization- Configures pip to use Tsinghua mirror
- Sets Playwright download host to npmmirror
- Installs playwright package
- Installs Chromium browser
- Installs ffmpeg via Homebrew
Platform-Specific Notes
Douyin (æé³):
- Accepts short links (v.douyin.com) or full URLs
- Extracts video from network HAR requests
- No login required
- Auto-detects modal_id from share text
Xiaohongshu (å°çº¢ä¹¦):
- Supports xiaohongshu.com and xhslink.com domains
- Captures video URL from page network requests
- No login required
- Works for both discovery and explore paths
Bilibili (Bç«):
- Requires login for HD quality (1080p+), otherwise limited to 480p
- Uses
__playinfo__page variable for video URL extraction - Downloads separate audio/video streams and merges with ffmpeg
- Cookie expiration auto-detected
Error Handling
| Exit Code | Meaning | Agent Action |
|---|---|---|
| 0 | Success | Proceed to next step |
| 1 | General error | Report error message to user |
| 2 | Login required | Initiate login workflow |
| Common Issues | Auto-Resolution |
|---|---|
| Missing dependencies | Run scripts/install_deps.sh |
| SSL certificate error | Script uses unverified SSL context |
| Video not captured | Content may require login or is image post |
| Low quality (Bilibili) | Prompt user to login for HD |
| Cookie expired | Re-run login command automatically |
| CDN URL expired | Retry download (URLs valid for few hours) |
Technical Details
Browser automation:
- Uses Playwright with Chromium
- Headless mode (user-invisible)
- Network HAR capture for video URL extraction
- Cookie persistence across sessions
Video processing:
- Bilibili: Merges DASH audio/video streams using ffmpeg
- Douyin/Xiaohongshu: Direct MP4 download
- Proper HTTP headers (User-Agent, Referer) for CDN access
File management:
- Default output:
~/Downloads/<sanitized_title>.mp4 - Title sanitization: Removes special chars, limits length
- Config directory:
~/.config/video-download/
Usage notes:
- Script handles all platform detection automatically from URL
- Agent should monitor Shell command exit codes to handle errors
- Use AskQuestion tool for interactive login confirmation
- Set block_until_ms: 0 for login command to avoid blocking
- Dependency installation takes 1-2 minutes on first run