This skill is based on the F2 frameworkto implement Douyin video batch downloading, providing efficient and stable batch download capabilities.
Feature Overview
- Single creator download - Enter a homepage link or ID to download all or a specified number
- Batch download - Specify multiple creators at once for batch processing
- Incremental download - Automatically skip already downloaded videos (determined by aweme_id)
- Cookie management - Prioritize automatic reading from the browser; if that fails, prompt for manual configuration
- Following list management - Maintain following.json to record processed creators
- Differential update - Supports downloading only videos that are on the homepage but not available locally
- Creator nickname folder - Use the creator nickname as the folder name for easier identification
- Custom download path - Supports a custom download directory; by default, uses the system Downloads directory
- Video compression - Use ffmpeg to compress videos and save storage space
- Video metadata - Scrape and save video statistics (likes, comments, favorites, shares)
- Data visualization - A web interface displays statistical information for creators and videos, with sorting and filtering support
Use Cases
- Server batch download: Deploy on a dedicated server to regularly batch scrape videos from specific creators
- Regularly update the video library: Automatically detect new videos and download only the missing parts
- Backup and migration: Video files are stored by category, making backup and subsequent processing easier
- Content analysis: Analyze creator content based on video statistics (likes, comments, favorites)
Configuration Instructions
Download Path Configuration
In config/config.yaml , configure the download path:
# 下载路径配置
# 留空则使用系统 Downloads 目录下的 "抖音视频下载" 子目录
# macOS: ~/Downloads/抖音视频下载
# Windows: C:\Users\<用户名>\Downloads\抖音视频下载
download_path: ""
# 自定义路径示例:
# download_path: "/Users/maoking/Movies/抖音"
# download_path: "D:\\Videos\\抖音"
Folder Naming
Video files are stored by creator nickname, for example:
~/Downloads/抖音视频下载/
├── 博主A/
│ ├── 2024-01-01_视频标题_xxx.mp4
│ └── ...
├── 博主B/
│ └── ...
└── data.js # Web 界面数据
Video Metadata
When downloading videos, the system automatically extracts and saves the following data:
| Field | Description |
|---|---|
aweme_id |
Unique video ID |
uid |
Author UID |
nickname |
Creator nickname |
desc |
Video description/caption |
create_time |
Publish time |
duration |
Video duration |
digg_count |
Like count |
comment_count |
Comment count |
collect_count |
Favorite count |
share_count |
Share count |
Data is stored in douyin_users.db in the video_metadata table.
Manually Extract/Update Metadata
# 扫描本地视频并提取元数据(基本信息)
python scripts/extract-metadata.py
# 查看统计摘要
python scripts/extract-metadata.py --stats
⚠️ Note:
--fetchoption is deprecated. It is recommended to usedownload-v2.pyto re-download the video, which will automatically save the statistics.
Quick Start
# 创建配置
mkdir -p config
cp config/config.yaml.example config/config.yaml
# 编辑配置(填写 Cookie)
${EDITOR:-nano} config/config.yaml
# 单个下载(推荐)
python scripts/download-v2.py "https://www.douyin.com/user/MS4wLjABAAAA..."
# 批量下载
python scripts/batch-download.py --all
# 交互式选择博主下载
python scripts/batch-download.py
# 采样下载(每个博主1个视频,快速更新数据)
python scripts/batch-download.py --sample
# 生成 Web 界面数据
python scripts/generate-data.py
# 查看 Web 界面
open ~/Downloads/抖音视频下载/index.html
Recommended Workflow
1. 添加博主 → python scripts/manage-following.py --batch
2. 批量下载 → python scripts/batch-download.py --all
3. 查看数据 → open ~/Downloads/抖音视频下载/index.html
Automatically save when downloading:
- ✅ Video file
- ✅ Likes, comments, favorites, shares
- ✅ Video description, publish time, duration
Directory structure
skills/douyin-batch-download/
├── SKILL.md # 本文件
├── references/
│ ├── INSTALLATION.md # 详细安装依赖说明
│ └── USAGE.md # 详细使用说明
├── scripts/
│ ├── utils/ # 工具模块
│ │ └── config.py # 统一配置加载
│ ├── download-v2.py # ✅ 推荐下载脚本(自动保存统计数据)
│ ├── batch-download.py # 批量下载入口
│ ├── download.py # ⚠️ 旧版下载脚本(已废弃)
│ ├── manage-following.py # 关注列表管理(添加/删除/搜索)
│ ├── sync-following.py # 从 F2 数据库同步 following.json
│ ├── compress.py # 视频压缩脚本
│ ├── extract-metadata.py # 视频元数据提取
│ ├── generate-data.py # 生成 Web 界面数据文件
│ ├── following.py # following.json 操作库
│ └── login.py # 扫码登录脚本
├── config/
│ ├── config.yaml.example # 配置模板
│ └── following.json # 关注列表(已下载的博主)
└── douyin_users.db # SQLite 数据库(用户信息 + 视频元数据)
Dependencies
System dependencies
| Dependency | Installation method |
|---|---|
| Chrome/Chromium | Download address |
| ffmpeg | macOS: brew install ffmpeg / Ubuntu: sudo apt install ffmpeg |
ffmpeg Used for the video compression feature; if you only need the download feature, it can be left uninstalled.
Python packages
| Package name | Purpose |
|---|---|
f2 |
Douyin video download framework |
playwright |
Browser automation (QR code login) |
pyyaml |
YAML configuration file parsing |
httpx |
Asynchronous HTTP client |
aiofiles |
Asynchronous file operations |
Detailed installation instructions: see references/INSTALLATION.md
Detailed usage instructions: see references/USAGE.md
Reference resources
- F2 official documentation:https://f2.wiki
- F2 GitHub:https://github.com/Johnserf-Seed/f2
Working with other skills
Local ASR speech-to-text
Downloaded videos can use the local-asr skill to transcribe videos into timestamped Markdown files.
How to combine: First use the Douyin download skill to obtain videos, then use the local-asr skill for transcription. The two skills run independently and can be flexibly combined as needed.