Douyin Video Processor
Process Douyin (TikTok China) share links: extract video speech to text, get watermark-free download URLs, and download videos locally.
First-Time Setup
Before using any script, install the Python dependencies:
CODEBLOCK0
This installs requests and dashscope. Only needed once.
Environment Variable
The text extraction feature requires DASHSCOPE_API_KEY from Alibaba Cloud Bailian.
The user must set this before you can call douyin_extract_text.py. If it is not set, tell the user:
To use text extraction, you need an Alibaba Cloud Bailian API key.
- 1. Go to https://help.aliyun.com/zh/model-studio/get-api-key
- Create an API key (starts with
sk-) - Set it: INLINECODE5
The other two scripts (parse and download) do not need any API key.
Available Scripts
1. Parse Video Info (no API key needed)
Extract video metadata (ID, title, watermark-free URL) from a Douyin share link.
CODEBLOCK1
Input: A Douyin share link or text containing one (e.g. https://v.douyin.com/xxxxx/ or a full share text like "7.29 复制打开抖音... https://v.douyin.com/xxxxx/")
Output: JSON to stdout:
CODEBLOCK2
When to use: User wants to see video info, or you need the download URL without downloading the file.
2. Download Video (no API key needed)
Download a watermark-free video file to local disk.
CODEBLOCK3
Input:
- - Arg 1: Douyin share link or text containing one
- Arg 2 (optional): Output directory, defaults to current directory
Output: JSON to stdout:
CODEBLOCK4
When to use: User asks to download a Douyin video, save a video, or get the actual video file.
3. Extract Text from Video (requires DASHSCOPEAPIKEY)
Parse a Douyin share link, then transcribe the video speech to text using Alibaba Cloud ASR.
CODEBLOCK5
Input:
- - Arg 1: Douyin share link or text containing one
- Arg 2 (optional): ASR model name, defaults to INLINECODE8
Output: JSON to stdout:
CODEBLOCK6
When to use: User wants to know what's said in a Douyin video, asks to transcribe, extract text, get subtitles, or summarize video content.
Important: Always pass DASHSCOPE_API_KEY as an environment variable in the command. If the key is not set, the script will return an error with setup instructions.
Error Handling
All scripts return JSON even on failure:
CODEBLOCK7
Common errors and what to tell the user:
| Error message contains | User-facing guidance |
|---|
| INLINECODE10 | The input doesn't contain a valid Douyin URL. Ask the user to paste the full share link. |
| INLINECODE11 |
The video may be deleted, private, or region-locked. Ask the user to verify the link opens in a browser. |
|
DASHSCOPE_API_KEY.*not set | The API key is missing. Guide the user through setup (see Environment Variable section above). |
|
Transcription failed | ASR API error — the key may be invalid or quota exhausted. Ask the user to check their Alibaba Cloud console. |
|
dashscope package not installed | Run
bash scripts/install_deps.sh to install dependencies. |
Batch Processing
When the user provides multiple Douyin links, process them sequentially. For each link:
- 1. Call the appropriate script
- Parse the JSON output
- Collect results
- Present a summary table to the user
For batch text extraction, first parse all links with douyin_parse.py to validate them, then extract text only from the valid ones with douyin_extract_text.py. This avoids wasting API calls on broken links.
Cost Awareness
| Script | API Cost | Speed |
|---|
| INLINECODE18 | Free | ~1-2s |
| INLINECODE19 |
Free | depends on video size |
|
douyin_extract_text.py | Alibaba Cloud ASR (very low cost) | ~10-30s |
Always prefer douyin_parse.py first when you just need to verify a link or get the download URL.
External Endpoints
| Endpoint | Purpose | Data Sent |
|---|
| INLINECODE22 | Resolve Douyin share link redirects | Share URL |
| INLINECODE23 |
Fetch video page to extract metadata | Video ID |
| Douyin CDN | Download video file (douyin_download.py only) | None (GET request) |
|
https://dashscope.aliyuncs.com/api/* | Alibaba Cloud ASR (douyin
extracttext.py only) | Video URL + API key |
Security & Privacy
- -
DASHSCOPE_API_KEY is only sent to Alibaba Cloud's official API endpoint (dashscope.aliyuncs.com) - No data is collected, stored, or transmitted by this skill beyond the API calls listed above
- Downloaded video files are saved only where the user specifies
- No persistent background processes
Trust Statement
By using this skill, Douyin share links are sent to Douyin/ByteDance servers for URL resolution, and video URLs may be sent to Alibaba Cloud (Aliyun) for speech-to-text transcription. Only install this skill if you trust these services.
抖音视频处理器
处理抖音分享链接:提取视频语音转文字、获取无水印下载链接,以及本地下载视频。
首次设置
使用任何脚本前,请先安装Python依赖:
bash
bash scripts/install_deps.sh
这将安装requests和dashscope。仅需执行一次。
环境变量
文本提取功能需要阿里云百炼的DASHSCOPEAPIKEY。
用户必须在调用douyinextracttext.py前设置该变量。若未设置,请告知用户:
要使用文本提取功能,您需要阿里云百炼的API密钥。
- 1. 访问 https://help.aliyun.com/zh/model-studio/get-api-key
- 创建API密钥(以sk-开头)
- 设置密钥:/secrets set DASHSCOPEAPIKEY sk-您的密钥
另外两个脚本(解析和下载)无需任何API密钥。
可用脚本
1. 解析视频信息(无需API密钥)
从抖音分享链接中提取视频元数据(ID、标题、无水印链接)。
bash
python3 scripts/douyin_parse.py 分享链接
输入: 抖音分享链接或包含链接的文本(例如 https://v.douyin.com/xxxxx/ 或完整分享文本如 7.29 复制打开抖音... https://v.douyin.com/xxxxx/)
输出: JSON格式输出到标准输出:
json
{
status: success,
video_id: 7345678901234567890,
title: 视频标题,
download_url: https://...
}
使用场景: 用户想查看视频信息,或您需要下载链接但无需下载文件。
2. 下载视频(无需API密钥)
将无水印视频文件下载到本地磁盘。
bash
python3 scripts/douyin_download.py 分享链接 [输出目录]
输入:
- - 参数1:抖音分享链接或包含链接的文本
- 参数2(可选):输出目录,默认为当前目录
输出: JSON格式输出到标准输出:
json
{
status: success,
video_id: 7345678901234567890,
title: 视频标题,
file_path: /绝对路径/视频.mp4,
size_bytes: 12345678
}
使用场景: 用户要求下载抖音视频、保存视频或获取实际视频文件。
3. 从视频提取文本(需要DASHSCOPEAPIKEY)
解析抖音分享链接,然后使用阿里云ASR将视频语音转录为文本。
bash
DASHSCOPEAPIKEY=$DASHSCOPEAPIKEY python3 scripts/douyinextracttext.py 分享链接 [模型]
输入:
- - 参数1:抖音分享链接或包含链接的文本
- 参数2(可选):ASR模型名称,默认为paraformer-v2
输出: JSON格式输出到标准输出:
json
{
status: success,
video_id: 7345678901234567890,
title: 视频标题,
text: 视频中完整的转录文本内容...
}
使用场景: 用户想了解抖音视频中的说话内容,要求转录、提取文本、获取字幕或总结视频内容。
重要提示: 始终在命令中将DASHSCOPEAPIKEY作为环境变量传递。如果密钥未设置,脚本将返回错误并附带设置说明。
错误处理
所有脚本在失败时也返回JSON格式:
json
{
status: error,
error: 人类可读的错误信息
}
常见错误及对用户的指导:
| 错误信息包含 | 面向用户的指导 |
|---|
| No valid share link | 输入不包含有效的抖音URL。请用户粘贴完整的分享链接。 |
| Failed to parse video info |
视频可能已被删除、设为私密或存在地区限制。请用户验证链接能否在浏览器中打开。 |
| DASHSCOPE
APIKEY.*not set | API密钥缺失。引导用户完成设置(参见上方环境变量部分)。 |
| Transcription failed | ASR API错误——密钥可能无效或配额已用完。请用户检查阿里云控制台。 |
| dashscope package not installed | 运行bash scripts/install_deps.sh安装依赖。 |
批量处理
当用户提供多个抖音链接时,按顺序处理。对每个链接:
- 1. 调用相应脚本
- 解析JSON输出
- 收集结果
- 向用户呈现汇总表
对于批量文本提取,首先使用douyinparse.py解析所有链接以验证其有效性,然后仅对有效链接使用douyinextract_text.py提取文本。这样可以避免在无效链接上浪费API调用。
成本说明
| 脚本 | API成本 | 速度 |
|---|
| douyinparse.py | 免费 | ~1-2秒 |
| douyindownload.py |
免费 | 取决于视频大小 |
| douyin
extracttext.py | 阿里云ASR(成本极低) | ~10-30秒 |
当您只需验证链接或获取下载链接时,始终优先使用douyin_parse.py。
外部端点
| 端点 | 用途 | 发送的数据 |
|---|
| https://v.douyin.com/ | 解析抖音分享链接重定向 | 分享URL |
| https://www.iesdouyin.com/share/video/ |
获取视频页面以提取元数据 | 视频ID |
| 抖音CDN | 下载视频文件(仅douyin_download.py) | 无(GET请求) |
| https://dashscope.aliyuncs.com/api/* | 阿里云ASR(仅douyin
extracttext.py) | 视频URL + API密钥 |
安全与隐私
- - DASHSCOPEAPIKEY仅发送至阿里云官方API端点(dashscope.aliyuncs.com)
- 除上述API调用外,本技能不会收集、存储或传输任何数据
- 下载的视频文件仅保存在用户指定的位置
- 无持久后台进程
信任声明
使用本技能时,抖音分享链接将被发送至抖音/字节跳动服务器进行URL解析,视频URL可能被发送至阿里云进行语音转文字转录。仅当您信任这些服务时,才安装本技能。