TikTok Downloader
This skill provides a robust workflow for downloading TikTok videos, overcoming common anti-bot measures like 403 Forbidden errors and login requirements.
Core Workflow
1. Single Video Download
To download a specific TikTok video, use the provided script:
CODEBLOCK0
2. Handling 403 Forbidden Errors
If
yt-dlp fails with a 403 error, follow these steps:
- 1. Navigate to the URL using the browser tool to establish a session and cookies.
- Run the script again. It is pre-configured to extract cookies from the browser's data directory (
/home/ubuntu/.browser_data_dir).
3. Batch Downloading
For multiple videos:
- 1. Save all URLs to a text file (e.g.,
urls.txt). - Use
yt-dlp with the following recommended flags:
CODEBLOCK1
Best Practices
- - Browser Navigation: Always visit at least one TikTok video page in the browser before starting a batch download to ensure cookies are fresh.
- Hashtag Pages: TikTok hashtag pages often require login. If a hashtag page fails to load, ask the user to log in via the browser or search for individual video URLs using the search tool.
- Output Naming: Use
%(uploader)s - %(title).80s.%(ext)s to keep filenames organized and avoid filesystem length limits. - Rate Limiting: For large batches, add
sleep between downloads to avoid IP bans.
TikTok 下载器
本技能提供了一套强大的工作流程,用于下载TikTok视频,能够克服常见的反爬措施,如403禁止错误和登录要求。
核心工作流程
1. 单个视频下载
要下载特定的TikTok视频,请使用提供的脚本:
bash
/home/ubuntu/skills/tiktok-downloader/scripts/download_tiktok.sh <视频URL> [输出目录]
2. 处理403禁止错误
如果yt-dlp因403错误而失败,请按以下步骤操作:
- 1. 使用浏览器工具导航到该URL,以建立会话和获取cookies。
- 再次运行脚本。该脚本已预先配置,可从浏览器的数据目录(/home/ubuntu/.browserdatadir)提取cookies。
3. 批量下载
对于多个视频:
- 1. 将所有URL保存到一个文本文件中(例如urls.txt)。
- 使用yt-dlp并添加以下推荐参数:
bash
yt-dlp --no-warnings \
--cookies-from-browser chromium:/home/ubuntu/.browser
datadir \
--user-agent Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36 \
--add-header Referer:https://www.tiktok.com/ \
-o %(uploader)s - %(title).80s.%(ext)s \
--batch-file urls.txt
最佳实践
- - 浏览器导航:在开始批量下载之前,务必先在浏览器中访问至少一个TikTok视频页面,以确保cookies是最新的。
- 话题标签页面:TikTok话题标签页面通常需要登录。如果话题标签页面加载失败,请让用户通过浏览器登录,或使用搜索工具搜索单个视频URL。
- 输出命名:使用%(uploader)s - %(title).80s.%(ext)s来保持文件名有序,并避免文件系统长度限制。
- 速率限制:对于大批量下载,在每次下载之间添加sleep命令,以避免IP被封禁。