Douyin Video Downloader
Downloads Douyin videos by opening the page in a headless browser, extracting the <video> source URL, and downloading via curl. This bypasses yt-dlp's cookie issues with Douyin's anti-scraping.
Prerequisites
- -
agent-browser (npm i -g agent-browser) - INLINECODE3
Usage
CODEBLOCK0
Supported URL Formats
- -
https://www.douyin.com/video/<id> — direct video page - INLINECODE5 — search results with video modal
- INLINECODE6 — share short links
- INLINECODE7 — note/image posts with video
Examples
CODEBLOCK1
How It Works
- 1. Normalize URL → extract video ID, construct direct video page URL
- Open page in
agent-browser (headless Chromium) - Extract
<video> element's currentSrc (CDN direct link) - Close browser
- Download MP4 via
curl with proper Referer header
Notes
- - No login required — fresh browser session is sufficient
- Video title auto-detected from page title for filename
- Large videos may take 30-60s to download depending on network
- CDN links are temporary (~2h validity); download promptly after extraction
抖音视频下载器
通过无头浏览器打开页面,提取
前置条件
- - agent-browser(npm i -g agent-browser)
- curl
使用方法
bash
python3 scripts/douyin_download.py [--output-dir DIR] [--filename NAME]
支持的 URL 格式
- - https://www.douyin.com/video/ — 直接视频页面
- https://www.douyin.com/search/...?modal_id= — 搜索结果中的视频弹窗
- https://v.douyin.com/
— 分享短链接 - https://www.douyin.com/note/ — 含视频的图文帖子
示例
bash
基本下载到 ~/Downloads 目录
python3 scripts/douyin_download.py https://www.douyin.com/video/7577715519366576522
自定义输出目录和文件名
python3 scripts/douyin_download.py https://www.douyin.com/video/7577715519366576522 \
-o ~/Videos -f my_video
从搜索页面 URL 下载
python3 scripts/douyin
download.py https://www.douyin.com/search/关键词?modalid=7577715519366576522
工作原理
- 1. 标准化 URL → 提取视频 ID,构建直接视频页面 URL
- 在 agent-browser(无头 Chromium)中打开页面
- 提取
- 关闭浏览器
- 通过 curl 下载 MP4,并设置正确的 Referer 请求头
注意事项
- - 无需登录 — 新的浏览器会话即可满足要求
- 视频标题会自动从页面标题中提取作为文件名
- 大视频文件下载可能需要 30-60 秒,具体取决于网络状况
- CDN 链接为临时链接(有效期约 2 小时);提取后请尽快下载