Universal Video Downloader
A versatile video downloading tool that supports multiple video platforms with intelligent platform detection and multiple download methods.
Supported Platforms
- - Douyin (抖音) - Chinese TikTok
- Bilibili (B站) - Chinese video platform
- YouTube - Global video platform
- TikTok - International short video
- Xigua (西瓜视频) - Chinese video platform
- Kuaishou (快手) - Chinese short video
- Generic - Any other video site (using browser mode)
Features
- - Automatic Platform Detection - Identifies platform from URL
- Smart Download Method - Uses yt-dlp for most sites, DrissionPage for anti-crawl sites
- Search & Download - Search Douyin by keyword and download results
- Batch Download - Download multiple videos at once
- Metadata Extraction - Saves title, author, platform info
Installation Options
Option 1: Docker (Recommended - No dependencies needed)
CODEBLOCK0
See DOCKER_README.md for detailed Docker usage.
Option 2: Python (Manual installation)
CODEBLOCK1
Usage
Download Single Video
CODEBLOCK2
Batch Download
CODEBLOCK3
Search and Download (Douyin)
CODEBLOCK4
Force Browser Mode
For sites with strong anti-crawl protection:
CODEBLOCK5
Specify Output Directory
CODEBLOCK6
Parameters
- -
url_or_keyword - Video URL or search keyword - INLINECODE2 - Video URL(s), can be used multiple times
- INLINECODE3 - Enable search mode (for Douyin)
- INLINECODE4 - Platform for search (default: douyin)
- INLINECODE5 - Number of videos to download (default: 5)
- INLINECODE6 - Output directory (default: D:\video_downloads)
- INLINECODE7 - Force use browser mode for downloading
Output Structure
CODEBLOCK7
Metadata Format
CODEBLOCK8
How It Works
Platform Detection
The tool automatically detects the platform from the URL:
- -
douyin.com → Douyin - INLINECODE9 /
b23.tv → Bilibili - INLINECODE11 /
youtu.be → YouTube - INLINECODE13 → TikTok
- etc.
Download Methods
- 1. yt-dlp (default for most platforms)
- Fast and reliable
- Supports 1000+ sites
- Best for YouTube, Bilibili, etc.
- 2. DrissionPage (for anti-crawl sites)
- Real browser automation
- Bypasses most anti-crawl protections
- Used automatically for Douyin
- Can be forced with
--browser flag
Search Functionality
For Douyin search:
- 1. Opens browser and navigates to search page
- Extracts video links from search results
- Downloads each video using browser session
Troubleshooting
"yt-dlp not installed"
CODEBLOCK9
"DrissionPage not installed"
CODEBLOCK10
Download fails for specific site
Try forcing browser mode:
CODEBLOCK11
Chrome not found (DrissionPage)
DrissionPage will auto-download Chrome on first use. If it fails:
- 1. Install Chrome manually
- Or set Chrome path in DrissionPage config
Connection errors
Some sites may block automated access. Try:
- - Using a VPN
- Waiting a few minutes between requests
- Using
--browser mode
Notes
- - Respect Copyright - Only download videos you have permission to use
- Rate Limiting - The tool includes delays to avoid overwhelming servers
- Cookie Support - DrissionPage mode uses browser cookies for authenticated access
- File Naming - Special characters in titles are sanitized for filesystem compatibility
Dependencies
- - Python 3.8+
- yt-dlp
- DrissionPage
- requests
- BeautifulSoup4 (optional, for parsing)
License
This tool is for educational and personal use only. Respect the terms of service of video platforms.
通用视频下载器
一款支持多视频平台的通用视频下载工具,具备智能平台识别和多种下载方式。
支持的平台
- - 抖音 - 中国短视频平台
- B站 - 中国视频平台
- YouTube - 全球视频平台
- TikTok - 国际短视频平台
- 西瓜视频 - 中国视频平台
- 快手 - 中国短视频平台
- 通用 - 其他任意视频网站(使用浏览器模式)
功能特性
- - 自动平台识别 - 从URL自动识别平台
- 智能下载方式 - 多数网站使用yt-dlp,反爬虫网站使用DrissionPage
- 搜索与下载 - 按关键词搜索抖音并下载结果
- 批量下载 - 一次性下载多个视频
- 元数据提取 - 保存标题、作者、平台信息
安装方式
方式一:Docker(推荐,无需安装依赖)
bash
构建镜像
docker build -t video-downloader .
下载视频
docker run -v $(pwd)/downloads:/app/downloads video-downloader URL
详细Docker使用方法请参见DOCKER_README.md。
方式二:Python(手动安装)
bash
所需依赖
pip install yt-dlp requests DrissionPage
DrissionPage浏览器自动化
首次使用时会自动下载Chrome浏览器
使用方法
下载单个视频
bash
抖音
python scripts/video_downloader.py https://www.douyin.com/video/xxx
B站
python scripts/video_downloader.py https://www.bilibili.com/video/xxx
YouTube
python scripts/video_downloader.py https://www.youtube.com/watch?v=xxx
其他任意平台
python scripts/video_downloader.py https://example.com/video
批量下载
bash
python scripts/video_downloader.py \
-u https://www.douyin.com/video/xxx \
-u https://www.bilibili.com/video/yyy \
-u https://www.youtube.com/watch?v=zzz
搜索并下载(抖音)
bash
搜索美女并下载5个视频
python scripts/video_downloader.py 美女 --search --count 5
自定义下载数量
python scripts/video_downloader.py 美女 --search --count 10
强制浏览器模式
适用于反爬虫保护较强的网站:
bash
python scripts/video_downloader.py https://example.com/video --browser
指定输出目录
bash
python scripts/video_downloader.py URL --output D:\\MyVideos
参数说明
- - urlorkeyword - 视频URL或搜索关键词
- --url, -u - 视频URL,可多次使用
- --search, -s - 启用搜索模式(仅抖音)
- --platform, -p - 搜索平台(默认:douyin)
- --count, -n - 下载视频数量(默认:5)
- --output, -o - 输出目录(默认:D:\video_downloads)
- --browser, -b - 强制使用浏览器模式下载
输出结构
video_downloads/
├── single20240312121029/
│ ├── 001videotitle.mp4
│ └── 001videotitle.json
├── batch20240312121102/
│ ├── 001_video1.mp4
│ ├── 001_video1.json
│ ├── 002_video2.mp4
│ ├── 002_video2.json
│ └── _summary.json
└── douyinkeyword20240312_121205/
├── 001_video1.mp4
├── 001_video1.json
├── 002_video2.mp4
├── 002_video2.json
└── _summary.json
元数据格式
json
{
index: 1,
title: 视频标题,
author: 上传者名称,
platform: douyin,
url: https://www.douyin.com/video/xxx,
videofilename: 001video_title.mp4,
filesizemb: 16.84,
download_time: 2024-03-12T12:20:30
}
工作原理
平台识别
工具会自动从URL中识别平台:
- - douyin.com → 抖音
- bilibili.com / b23.tv → B站
- youtube.com / youtu.be → YouTube
- tiktok.com → TikTok
- 其他
下载方式
- 1. yt-dlp(多数平台默认)
- 快速可靠
- 支持1000+网站
- 最适合YouTube、B站等
- 2. DrissionPage(反爬虫网站)
- 真实浏览器自动化
- 绕过大多数反爬虫保护
- 抖音自动使用
- 可通过--browser参数强制启用
搜索功能
抖音搜索流程:
- 1. 打开浏览器并导航至搜索页面
- 从搜索结果中提取视频链接
- 使用浏览器会话下载每个视频
故障排除
yt-dlp未安装
bash
pip install yt-dlp
DrissionPage未安装
bash
pip install DrissionPage
特定网站下载失败
尝试强制浏览器模式:
bash
python video_downloader.py URL --browser
Chrome未找到(DrissionPage)
DrissionPage首次使用时会自动下载Chrome。如果失败:
- 1. 手动安装Chrome
- 或在DrissionPage配置中设置Chrome路径
连接错误
某些网站可能阻止自动化访问。可尝试:
- - 使用VPN
- 请求之间等待几分钟
- 使用--browser模式
注意事项
- - 尊重版权 - 仅下载您有权使用的视频
- 请求频率限制 - 工具包含延迟以避免服务器过载
- Cookie支持 - DrissionPage模式使用浏览器Cookie进行认证访问
- 文件命名 - 标题中的特殊字符会被清理以确保文件系统兼容性
依赖项
- - Python 3.8+
- yt-dlp
- DrissionPage
- requests
- BeautifulSoup4(可选,用于解析)
许可协议
本工具仅供教育和个人使用。请遵守视频平台的服务条款。