关于 youtube-playlist
youtube-playlist 是面向 Agent 的 YouTube 播放列表浏览技能,可分页列出视频并获取字幕稿,也支持先查看频道播放列表。
主要功能
- 01分页列出播放列表视频
- 02按视频获取字幕稿
- 03浏览频道播放列表
- 04支持播放列表链接或 ID
适用场景
- 01整理播放列表中的视频
- 02批量获取列表视频字幕
- 03从频道查找目标播放列表
安装
复制下面的命令,在终端中运行。
npx skills add https:/ / github.com/ zeropointrepo/ youtube-skills --skill youtube-playlist安装后在 Claude Code 中输入/youtube-playlist确认已加载。
附带文件references/auth-setup.mdreferences/curl-examples.md
详细介绍
YouTube 播放列表
通过 TranscriptAPI.com 浏览播放列表并获取文字稿。
设置
如果未设置 $TRANSCRIPT_API_KEY,请阅读 references/auth-setup.md,并按照其中的说明获取并保存密钥。
必需的请求头
每个请求都需要两个请求头:
- Authorization:
Bearer $TRANSCRIPT_API_KEY - User-Agent: 已知时填写 Agent 的名称和版本(例如
HermesAgent/0.11.0、ClaudeCode/1.0)。版本可选,只填写 Agent 名称也可以。请勿省略此请求头或发送默认值,否则 Cloudflare 会返回 403(错误代码 1010)并阻止请求。
API 参考
完整的 OpenAPI 规范:transcriptapi.com/openapi.json — 请参阅此规范,了解最新的参数和架构。
GET /api/v2/youtube/playlist/videos — 每页 1 个额度
分页列出播放列表视频(每页 100 个)。接受 playlist 参数,可填写 YouTube 播放列表 URL 或播放列表 ID。
# First page
GET https://transcriptapi.com/api/v2/youtube/playlist/videos?playlist=PL_PLAYLIST_ID
Authorization: Bearer $TRANSCRIPT_API_KEY
User-Agent: YourAgent/1.0
# Next pages
GET https://transcriptapi.com/api/v2/youtube/playlist/videos?continuation=TOKEN
Authorization: Bearer $TRANSCRIPT_API_KEY
User-Agent: YourAgent/1.0
| 参数 | 必需 | 验证 |
|---|---|---|
playlist | 有条件必需 | 播放列表 URL 或 ID(前缀为 PL/UU/LL/FL/OL) |
continuation | 有条件必需 | 非空字符串 |
请准确提供 playlist 或 continuation 其中一个,不要同时提供两者。
接受的播放列表 ID 前缀:
PL— 用户创建的播放列表UU— 频道上传视频播放列表LL— 已点赞的视频FL— 收藏夹OL— 其他系统播放列表
响应:
{
"results": [
{
"videoId": "abc123xyz00",
"title": "Playlist Video Title",
"channelId": "UCuAXFkgsw1L7xaCfnd5JJOw",
"channelTitle": "Channel Name",
"channelHandle": "@handle",
"lengthText": "10:05",
"viewCountText": "1.5M views",
"thumbnails": [{ "url": "...", "width": 120, "height": 90 }],
"index": "0"
}
],
"playlist_info": {
"title": "Best Science Talks",
"numVideos": "47",
"description": "Top science presentations",
"ownerName": "TED",
"viewCount": "5000000"
},
"continuation_token": "4qmFsgKlARIYVVV1...",
"has_more": true
}
分页流程:
- 第一个请求:
?playlist=PLxxx— 返回前 100 个视频和continuation_token - 下一个请求:
?continuation=TOKEN— 返回接下来的 100 个视频和新令牌 - 重复此过程,直到
has_more: false或continuation_token: null
工作流:播放列表 → 文字稿
# 1. List playlist videos
GET https://transcriptapi.com/api/v2/youtube/playlist/videos?playlist=PL_PLAYLIST_ID
Authorization: Bearer $TRANSCRIPT_API_KEY
User-Agent: YourAgent/1.0
# 2. Get transcript from a video in the playlist
GET https://transcriptapi.com/api/v2/youtube/transcript?video_url=VIDEO_ID&format=text&include_timestamp=true&send_metadata=true
Authorization: Bearer $TRANSCRIPT_API_KEY
User-Agent: YourAgent/1.0
不知道播放列表 ID?从频道中查找
先浏览频道的播放列表(每页 1 个额度),然后列出其中一个播放列表的视频:
# 1. List the channel's playlists
GET https://transcriptapi.com/api/v2/youtube/channel/playlists?channel=@TED
Authorization: Bearer $TRANSCRIPT_API_KEY
User-Agent: YourAgent/1.0
# 2. List videos in the chosen playlist (playlistId from step 1)
GET https://transcriptapi.com/api/v2/youtube/playlist/videos?playlist=PLAYLIST_ID
Authorization: Bearer $TRANSCRIPT_API_KEY
User-Agent: YourAgent/1.0
从 URL 中提取播放列表 ID
在 https://www.youtube.com/playlist?list=PLrAXtmErZgOeiKm4sgNOknGvNjby9efdf 中,播放列表 ID 是 PLrAXtmErZgOeiKm4sgNOknGvNjby9efdf。你也可以直接将完整 URL 传给 playlist 参数。
错误
| 代码 | 含义 | 操作 |
|---|---|---|
| 400 | 两个参数都提供或都未提供 | 请准确提供 playlist 或 continuation 其中一个 |
| 402 | 没有额度 | transcriptapi.com/billing |
| 403/1010 | Cloudflare 阻止请求 | 添加或修正 User-Agent 请求头 |
| 404 | 未找到播放列表 | 检查播放列表是否公开 |
| 408 | 超时 | 重试一次 |
| 422 | 播放列表格式无效 | 必须是有效的播放列表 URL 或 ID |
每页 1 个额度。免费套餐:100 个额度,每分钟 300 个请求。
可直接复制的示例
此文件中的每个请求都提供了可直接运行的单行命令:references/curl-examples.md