Felo YouTube Subtitling Skill
When to Use
Trigger this skill when the user wants to:
- - Get subtitles or captions from a YouTube video
- Extract transcript by video ID or video URL
- Fetch subtitles in a specific language (e.g. en, zh-CN)
- Get subtitles with timestamps for analysis or translation
Trigger keywords (examples):
- - YouTube subtitles, get captions, video transcript, extract subtitles, YouTube 字幕
- Explicit:
/felo-youtube-subtitling, "use felo youtube subtitling"
Do NOT use for:
- - Real-time search (use
felo-search) - Web page content (use
felo-web-fetch) - Generating slides (use
felo-slides)
Setup
1. Get API key
- 1. Visit felo.ai
- Open Settings -> API Keys
- Create and copy your API key
2. Configure environment variable
Linux/macOS:
CODEBLOCK0
Windows PowerShell:
CODEBLOCK1
How to Execute
Option A: Use the bundled script or packaged CLI
Script (from repo):
CODEBLOCK2
Packaged CLI (after npm install -g felo-ai):
CODEBLOCK3
Options:
| Option | Default | Description |
|---|
| INLINECODE5 / INLINECODE6 | (required) | YouTube video URL or video ID (e.g. https://youtube.com/watch?v=ID or dQw4w9WgXcQ) |
| INLINECODE9 / INLINECODE10 |
- | Subtitle language code (e.g.
en,
zh-CN) |
|
--with-time | false | Include start/duration timestamps in each segment |
|
--json /
-j | false | Print full API response as JSON |
You can pass either a full YouTube link or the 11-character video ID:
- - Supported URLs:
https://www.youtube.com/watch?v=ID, https://youtu.be/ID, INLINECODE18 - Or plain ID: INLINECODE19
Examples:
CODEBLOCK4
Option B: Call API with curl
CODEBLOCK5
API Reference (summary)
- - Endpoint: INLINECODE20
- Base URL:
https://openapi.felo.ai. Override with FELO_API_BASE env if needed. - Auth: INLINECODE23
Query parameters
| Parameter | Type | Required | Default | Description |
|---|
| video_code | string | Yes | - | YouTube video ID (e.g. dQw4w9WgXcQ) |
| language |
string | No | - | Language code (e.g. en, zh-CN) |
| with_time | boolean | No | false | Include start/duration per segment |
Response (200)
CODEBLOCK6
With with_time=false, start/duration may be absent or zero. contents[].text is always present.
Error codes
| HTTP | Code | Description |
|---|
| 400 | - | Parameter validation failed (e.g. missing videocode) |
| 401 |
INVALIDAPI_KEY | API key invalid or revoked |
| 500/502 | YOUTUBE
SUBTITLINGFAILED | Service error or subtitles unavailable for video |
Output Format
- - Without
--json: print title and then each segment's text (one per line or concatenated). If --with-time, output includes timestamps. - With
--json: print full API response.
On failure (no subtitles, API error): stderr message and exit 1. Example:
CODEBLOCK7
Important Notes
- - Not all videos have subtitles; the API may return an error for some videos.
- Language code must match a subtitle track available for the video.
- Same
FELO_API_KEY as other Felo skills.
References
Felo YouTube 字幕技能
使用场景
当用户想要以下操作时触发此技能:
- - 获取YouTube视频的字幕或隐藏式字幕
- 通过视频ID或视频URL提取转录文本
- 获取特定语言的字幕(例如en、zh-CN)
- 获取带时间戳的字幕用于分析或翻译
触发关键词(示例):
- - YouTube字幕、获取字幕、视频转录、提取字幕、YouTube 字幕
- 明确指令:/felo-youtube-subtitling、使用felo youtube字幕功能
不适用场景:
- - 实时搜索(请使用felo-search)
- 网页内容(请使用felo-web-fetch)
- 生成幻灯片(请使用felo-slides)
设置
1. 获取API密钥
- 1. 访问 felo.ai
- 打开设置 -> API密钥
- 创建并复制您的API密钥
2. 配置环境变量
Linux/macOS:
bash
export FELOAPIKEY=your-api-key-here
Windows PowerShell:
powershell
$env:FELOAPIKEY=your-api-key-here
执行方式
方式A:使用捆绑脚本或打包的CLI
脚本(来自仓库):
bash
node felo-youtube-subtitling/scripts/runyoutubesubtitling.mjs --video-code dQw4w9WgXcQ [选项]
打包的CLI(执行npm install -g felo-ai后):
bash
felo youtube-subtitling -v dQw4w9WgXcQ [选项]
简写形式:-v(视频代码)、-l(语言)、-j(JSON格式)
选项:
| 选项 | 默认值 | 描述 |
|---|
| --video-code / -v | (必填) | YouTube 视频URL 或 视频ID(例如 https://youtube.com/watch?v=ID 或 dQw4w9WgXcQ) |
| --language / -l |
- | 字幕语言代码(例如 en、zh-CN) |
| --with-time | false | 在每个片段中包含开始/持续时间戳 |
| --json / -j | false | 以JSON格式打印完整API响应 |
您可以传入完整的YouTube链接或11位字符的视频ID:
- - 支持的URL:https://www.youtube.com/watch?v=ID、https://youtu.be/ID、https://youtube.com/embed/ID
- 或纯ID:dQw4w9WgXcQ
示例:
bash
使用视频URL
node felo-youtube-subtitling/scripts/run
youtubesubtitling.mjs --video-code https://www.youtube.com/watch?v=dQw4w9WgXcQ
felo youtube-subtitling -v https://youtu.be/dQw4w9WgXcQ
使用视频ID
node felo-youtube-subtitling/scripts/run
youtubesubtitling.mjs -v dQw4w9WgXcQ --language zh-CN
带时间戳
node felo-youtube-subtitling/scripts/run
youtubesubtitling.mjs -v dQw4w9WgXcQ --with-time --json
方式B:使用curl调用API
bash
curl -X GET https://openapi.felo.ai/v2/youtube/subtitling?video_code=dQw4w9WgXcQ \
-H Authorization: Bearer $FELOAPIKEY
API参考(摘要)
- - 端点:GET /v2/youtube/subtitling
- 基础URL:https://openapi.felo.ai。如有需要,可通过FELOAPIBASE环境变量覆盖。
- 认证:Authorization: Bearer YOURAPIKEY
查询参数
| 参数 | 类型 | 必填 | 默认值 | 描述 |
|---|
| video_code | 字符串 | 是 | - | YouTube视频ID(例如 dQw4w9WgXcQ) |
| language |
字符串 | 否 | - | 语言代码(例如 en、zh-CN) |
| with_time | 布尔值 | 否 | false | 每个片段包含开始/持续时间 |
响应(200)
json
{
code: 0,
message: success,
data: {
title: 视频标题,
contents: [
{ start: 0.32, duration: 14.26, text: 字幕文本 }
]
}
}
当with_time=false时,start/duration可能不存在或为零。contents[].text始终存在。
错误代码
| HTTP | 代码 | 描述 |
|---|
| 400 | - | 参数验证失败(例如缺少videocode) |
| 401 |
INVALIDAPI_KEY | API密钥无效或已撤销 |
| 500/502 | YOUTUBE
SUBTITLINGFAILED | 服务错误或视频无可用字幕 |
输出格式
- - 不使用--json:打印标题,然后打印每个片段的文本(每行一个或拼接)。如果使用--with-time,输出包含时间戳。
- 使用--json:打印完整API响应。
失败时(无字幕、API错误):输出到stderr并退出代码1。示例:
YouTube字幕获取失败,视频 dQw4w9WgXcQ:YOUTUBESUBTITLINGFAILED
重要说明
- - 并非所有视频都有字幕;某些视频API可能返回错误。
- 语言代码必须与视频可用的字幕轨道匹配。
- 使用与其他Felo技能相同的FELOAPIKEY。
参考