YouTube Transcript Extractor API Skill
📖 Introduction
This skill provides a one-stop video transcript extraction service using BrowserAct's YouTube Transcript Extractor API template. It can directly extract full video transcripts and metadata from any YouTube video. By simply providing the TargetURL, you can get clean, ready-to-use transcript and metadata.
✨ Features
- 1. No hallucinations, ensuring stable and accurate data extraction: Pre-set workflows avoid generative AI hallucinations.
- No CAPTCHA issues: No need to handle reCAPTCHA or other verification challenges.
- No IP access restrictions or geofencing: No need to deal with regional IP limits.
- Faster execution: Compared to pure AI-driven browser automation solutions, task execution is much faster.
- High cost-effectiveness: Significantly reduces data acquisition costs compared to AI solutions that consume large amounts of tokens.
🔑 API Key Setup
Before running, you must check the
BROWSERACT_API_KEY environment variable. If it is not set, do not take any other actions; you must request and wait for the user to provide it.
The Agent must inform the user at this point:
"Since you haven't configured the BrowserAct API Key yet, please go to the BrowserAct Console to get your Key first."
🛠️ Input Parameters
The Agent should configure the following parameter based on the user's needs when calling the script:
- 1. TargetURL (Target URL)
-
Type:
string
-
Description: The URL of the YouTube video you want to extract the transcript and metadata from.
-
Example: INLINECODE2
🚀 Usage (Recommended)
The Agent should execute the following independent script to achieve "one command, get results":
CODEBLOCK0
⏳ Running Status Monitoring
Since this task involves automated browser operations, it may take a long time (several minutes). While running, the script will
continuously output status logs with timestamps (e.g.,
[14:30:05] Task Status: running).
Agent Instructions:
- - While waiting for the script to return results, please keep an eye on the terminal output.
- As long as the terminal continues to output new status logs, it means the task is running normally. Do not misjudge it as a deadlock or unresponsiveness.
- Only if the status remains unchanged for a long time or the script stops outputting without returning a result, should you consider triggering the retry mechanism.
📊 Data Output Description
After successful execution, the script will parse and print the results directly from the API response. The results include:
- -
video_title: The title of the YouTube video - INLINECODE5 : The direct link to the original video
- INLINECODE6 : The name of the channel publishing the video
- INLINECODE7 : The URL of the publisher's YouTube channel
- INLINECODE8 : The number of likes the video has received
- INLINECODE9 : The complete extracted transcript/subtitles of the video
⚠️ Error Handling & Retry
During script execution, if an error occurs (such as network fluctuation or task failure), the Agent should follow this logic:
- 1. Check output content:
- If the output
contains "Invalid authorization", it means the API Key is invalid or expired. In this case,
do not retry, and guide the user to check and provide the correct API Key.
- If the output
does not contain "Invalid authorization" but the task execution fails (for example, the output starts with
Error: or returns an empty result), the Agent should
automatically try to execute the script one more time.
- 2. Retry limits:
- Automatic retry is limited to
only once. If the second attempt still fails, stop retrying and report the specific error message to the user.
YouTube 字幕提取 API 技能
📖 简介
本技能利用 BrowserAct 的 YouTube 字幕提取 API 模板,提供一站式视频字幕提取服务。可直接从任何 YouTube 视频中提取完整的视频字幕和元数据。只需提供目标网址(TargetURL),即可获得干净、可直接使用的字幕和元数据。
✨ 功能特点
- 1. 无幻觉,确保稳定准确的数据提取:预设工作流程避免了生成式 AI 的幻觉问题。
- 无验证码困扰:无需处理 reCAPTCHA 或其他验证挑战。
- 无 IP 访问限制或地理封锁:无需应对区域 IP 限制。
- 执行速度更快:相比纯 AI 驱动的浏览器自动化方案,任务执行速度显著提升。
- 高性价比:相比消耗大量 Token 的 AI 方案,大幅降低数据获取成本。
🔑 API 密钥设置
运行前,必须检查 BROWSERACT
APIKEY 环境变量。如果未设置,请勿执行任何其他操作;必须请求并等待用户提供。
此时 Agent 必须告知用户:
由于您尚未配置 BrowserAct API 密钥,请先前往 BrowserAct 控制台 获取您的密钥。
🛠️ 输入参数
Agent 在调用脚本时应根据用户需求配置以下参数:
- 1. 目标网址(TargetURL)
-
类型:string
-
描述:要提取字幕和元数据的 YouTube 视频网址。
-
示例:https://www.youtube.com/watch?v=st534T7-mdE
🚀 使用方法(推荐)
Agent 应执行以下独立脚本,实现一键执行,获取结果:
bash
调用示例
python -u ./scripts/youtube
transcriptextractor_api.py TargetURL
⏳ 运行状态监控
由于此任务涉及自动化浏览器操作,可能需要较长时间(数分钟)。运行期间,脚本将
持续输出带时间戳的状态日志(例如 [14:30:05] 任务状态:运行中)。
Agent 操作说明:
- - 在等待脚本返回结果时,请密切关注终端输出。
- 只要终端持续输出新的状态日志,即表示任务正常运行。请勿误判为死锁或无响应。
- 仅当状态长时间未变化或脚本停止输出且未返回结果时,才应考虑触发重试机制。
📊 数据输出说明
执行成功后,脚本将直接从 API 响应中解析并打印结果。结果包括:
- - videotitle:YouTube 视频的标题
- videourl:原始视频的直接链接
- publisher:发布视频的频道名称
- channellink:发布者 YouTube 频道的链接
- videolikes_count:视频获得的点赞数
- transcript:视频的完整提取字幕/文本
⚠️ 错误处理与重试
脚本执行过程中,如果发生错误(如网络波动或任务失败),Agent 应遵循以下逻辑:
- 1. 检查输出内容:
- 如果输出
包含 Invalid authorization,表示 API 密钥无效或已过期。此时
请勿重试,引导用户检查并提供正确的 API 密钥。
- 如果输出
不包含 Invalid authorization 但任务执行失败(例如输出以 Error: 开头或返回空结果),Agent 应
自动尝试重新执行脚本一次。
- 2. 重试限制:
- 自动重试
仅限一次。如果第二次尝试仍然失败,停止重试并向用户报告具体的错误信息。