YouTube 数据查询工具,通过 MaxHub API 接入 YouTube 平台 Web / Web V2 双版本接口,覆盖视频详情、播放流(Streams)、字幕(Captions)、推荐与趋势、频道资料、频道视频与 Shorts、社区帖子(Community Posts)、视频评论与回复、综合搜索与建议词等全部能力。专注服务于 YouTube 内容创作者、跨境短视频研究、频道竞品分析与字幕翻译爬取业务,帮助用户提炼爆款选题、量化频道增长、批量采集字幕与评论。
> ### 📋 数据传输与隐私声明(请认真阅读)
>
> 1. 第三方传输:您提供的所有 ID、关键词、链接、cookie 等参数都会通过 HTTPS 发送到 https://www.aconfig.cn(MaxHub 数据服务)进行处理。
> 2. UGC 隐私:拉回的评论 / 弹幕 / 动态 / 私信 / 联系人等内容可能包含个人信息或敏感 UGC,请勿写入未授权的数据库或公开发布。
> 3. 凭证保护:建议使用独立测试账号、定期轮换 API Key;禁止传入主力生产账号的 cookie 或 session 凭证。
> 4. 合规责任:使用方需自行确保符合所在地区的数据保护法律(《个人信息保护法》/ GDPR / 平台 ToS 等),平台账号的合规性由使用方承担。
请前往 MaxHub 控制台 注册账号并获取 API Key。
方案 1:OpenClaw 配置
将 MAXHUB_API_KEY 添加到 ~/.openclaw/openclaw.json 中:
{ "env": { "MAXHUB_API_KEY": "ak_xxxx..." } }
方案 2:终端环境变量
export MAXHUB_API_KEY="ak_xxxx..."
本 Skill 不需要额外脚本依赖,所有调用通过 curl 完成 HTTP 请求即可,无第三方库依赖。
| 环境变量 | 说明 | 是否必填 | 获取方式 |
|---|---|---|---|
| --- | --- | --- | --- |
MAXHUB_API_KEY | MaxHub 数据 API Key | 是 | MaxHub 控制台 |
> 此小节定义 agent 在每次接到用户请求时的标准决策流程。严格按此顺序执行可大幅提升命中率与减少误调用。
| 步骤 | 何时读 | 加载文件 | 估算 token |
|---|---|---|---|
| ------ | ------- | --------- | ----------- |
| ① 永远先读 | 接到任何请求时 | SKILL.md §0.1(不支持清单)+ §4(本节) | ~1K |
| ② 选择 recipe | 用户语义清晰时 | references/recipes/_index.md(仅索引) | ~1.5K |
| ③ 加载 recipe 详情 | 匹配到具体 recipe 时 | references/recipes/ 的对应段落 | ~500/段 |
| ④ 加载端点详情 | 自定义链路或参数不明时 | references/ 单文件 | ~3K |
| ⑤ 路径白名单校验 | 调用前 | grep '(禁止整体读) | ~50 行 |
| ⑥ 跨端点字段路由 | 链式调用时 | references/param-mappings.md § 字段流字典 | ~1K |
references/recipes/_index.md,扫 trigger_keywords 列references/atoms/_index.md,按 chain_role 列定位起点(starter)和终点(terminal)⭐⭐⭐ 首选 标记的端点;不到必要不用 ⭐ 条件 端点param-mappings.md § 字段流字典 决定,禁止自行猜 json_path| 端点 risk | 必做自检 | 步骤数 |
|---|---|---|
| ---------- | --------- | ------- |
risk: low | ① 路径在 endpoints_whitelist.yaml | 1 步 |
risk: medium | ① 路径 ② method ③ 必填参数 ④ 写入确认 | 4 步 |
risk: high | 4 步 + 显式向用户确认参数与意图 | 5 步 |
risk: critical(restricted) | 6 步高风险确认流程(详见 §高风险能力清单) | 6 步 |
> 旧 SKILL 强制所有调用都做 4 步——现按 risk 等级简化。low 端点(占绝大多数)只校验路径即可。
| 现象 | 行动 | 重试 |
|---|---|---|
| ------ | ------ | ------ |
| 404 / 410 | §3.1(A) 5 步防臆造自检 → 通过才 STOP;禁止自改路径段重试 | 0 |
| 400 / 422 | §3.1(B) 6 步防参数臆造自检 → 通过才修参重试 | ≤1 |
| 401 / 402 / 403 | STOP,告知用户去 https://www.aconfig.cn 处理 | 0 |
| 429 | 读 Retry-After 退避;无该头时指数退避+jitter | ≤2 |
| 5xx | 等 3 秒重试 → 仍失败走端点级"降级/替换" | 1 |
HTTP 200 + code != 0 | 读 message_zh 报告用户;不重试(业务错误重试无用) | 0 |
https://www.aconfig.cn 三方接口| 规则 | 说明 |
|---|---|
| ------ | ------ |
| 🔒 只读 | 本技能仅用于数据查询和分析,不执行写入 / 账户操作 |
| 🚫 禁止臆造路径 | 仅使用 references/endpoints_whitelist.yaml 中的端点,不得自行拼接、改 web/web_v2 段、加路径 |
| 📋 数据流向第三方 | 所有请求发送至 https://www.aconfig.cn,请使用独立测试账号并定期轮换 API Key |
| 🔑 凭证保护 | 不暴露 API Key、Cookie、Token 至日志或对话 |
| 🔀 版本不互通 | Web 与 Web V2 端点参数不兼容,禁止跨版本套用参数名(如 search_query vs keyword) |
Step 1 — 检查 API Key
[ -n "${MAXHUB_API_KEY:-}" ] && echo "ok" || echo "missing"
若返回 missing,停止并提示用户配置 MAXHUB_API_KEY。
Step 2 — 匹配意图 → 选择 reference
按用户目标从下表选择对应 reference 文件,每个文件自包含其领域的全部端点定义:
| 用户目标 | 加载文件 | 覆盖范围 |
|---|---|---|
| --------- | --------- | --------- |
| 查视频 / 流媒体 / 字幕 / 推荐 / 趋势 / 签名 URL | references/video.md | 视频详情、Streams、Captions、相关视频、趋势视频(13 端点) |
| 查频道 / 长视频 / Shorts / 社区帖 / ID 互转 | references/channel.md | 频道信息、视频、Shorts、社区帖子、ID/URL 互转(12 端点) |
| 综合搜索 / Shorts 搜索 / 频道搜索 / 建议词 | references/search.md | 综合搜索、Shorts 搜索、频道搜索、搜索建议(7 端点) |
| 查评论 / 回复 / 帖子详情 / 帖子评论 | references/comments.md | 视频评论、评论回复、社区帖子详情与评论回复(5 端点) |
| 跨端点参数查询 / 字段流追溯 | references/param-mappings.md | 全局红线 + 端点路由 + Web/Web V2 字段流字典 + 错误处理总览 |
| 路径白名单硬校验 | references/endpoints_whitelist.yaml | 37 端点的硬白名单 + Pre-call 4 步自检协议 |
Step 3 — 构建最小调用计划
Step 4 — 执行并验证
endpoints_whitelist.yaml 完成 4 步 Pre-call 自检(路径 → method → 必填 → 写入确认)message_zh 报告用户,不重试| 用户场景 | 链路 | 字段流 |
|---|---|---|
| --------- | ------ | ------- |
| 搜索 → 视频详情 | web_v2_get_general_search_v2 → web_v2_get_video_info_v2 | keyword → video_id |
| 查视频 + 评论 + 回复 | web_v2_get_video_info → web_v2_get_video_comments → web_v2_get_video_comment_replies | video_id → continuation_token 接力 |
| 查频道 → 视频列表 | web_get_channel_id → web_get_channel_info → web_get_channel_videos_v2 | channel_name → channel_id |
| 频道全面分析 | web_v2_get_channel_description → web_v2_get_channel_videos + web_v2_get_channel_shorts + web_v2_get_channel_community_posts | channel_id 复用 |
| 字幕双端互降 | web_v2_get_video_captions 失败 → 降级 web_get_video_subtitles | video_id → subtitle_url |
| 视频流 + 签名 URL | web_v2_get_video_streams → web_v2_get_signed_stream_url | video_id → itag |
| 社区帖子 + 评论 | web_v2_get_post_detail → web_v2_get_post_comments → web_v2_get_post_comment_replies | post_id → continuation_token |
> ⚠️ 字幕选型陷阱:web/get_video_subtitles 必填 subtitle_url(需要先从 get_video_info 拿到字幕地址),而 web_v2/get_video_captions 直接传 video_id 即可。优先使用 V2,失败再回退 V1。
收到 404 时(A):
web/ vs web_v2/ 段)→ 不在清单中 STOP收到 400 / 422 时(B):
search_query、V2 用 keyword)video_id / video_url 二选一)nextToken 用到 V2 的 continuation_token)message_zh 排查| 维度 | Web (V1) | Web V2 |
|---|---|---|
| --- | --- | --- |
| 端点数量 | 13+ | 24+ |
| 字段丰富度 | 基础 | 丰富(含 need_format / language_code / country_code 多语言) |
| 翻页参数 | nextToken / continuation_token | 统一 continuation_token |
| 字幕能力 | get_video_subtitles 需 subtitle_url | get_video_captions 仅需 video_id |
| 推荐场景 | 趋势视频 / 频道短视频 / 字幕 URL 抓取 | 视频 / 频道 / 评论 / 搜索主链路 |
| 触发条件 | 推荐操作 |
|---|---|
| --------- | --------- |
| 合法路径持续 404 / 410 | skillhub upgrade maxhub-youtube(国内)或 clawhub upgrade maxhub-youtube(国际) |
| 用户问"版本是多少" | 当前版本 v3.7.2,访问 https://skillhub.cn/skills/maxhub-youtube |
| 多端点连续 410 | skillhub upgrade maxhub-youtube --force |
| 401 / 402 / 403 | 不是版本问题,去 https://www.aconfig.cn 处理 |
| 场景 | 命令 | ||
|---|---|---|---|
| --- | --- | ||
| 查 API Key | `[ -n "${MAXHUB_API_KEY:-}" ] && echo "ok" \ | \ | echo "missing"` |
| 查视频详情(V2) | curl -H "$maxhub_auth_header" "https://www.aconfig.cn/api/v1/youtube/web_v2/get_video_info?video_id=xxx" | ||
| 查视频字幕(V2) | curl -H "$maxhub_auth_header" "https://www.aconfig.cn/api/v1/youtube/web_v2/get_video_captions?video_id=xxx&language_code=en" | ||
| 查频道视频(V2) | curl -H "$maxhub_auth_header" "https://www.aconfig.cn/api/v1/youtube/web_v2/get_channel_videos?channel_id=UCxxx" | ||
| 综合搜索(V2) | curl -H "$maxhub_auth_header" "https://www.aconfig.cn/api/v1/youtube/web_v2/get_general_search_v2?keyword=xxx" | ||
| 检查 SKILL 更新 | skillhub info maxhub-youtube 或 clawhub info maxhub-youtube |
用户输入:「帮我看 YouTube 某视频的字幕」
Agent 执行步骤:
references/recipes/_index.md → 找到 trigger 命中 → 选最长匹配的 recipereferences/recipes/.md 中对应段落,拿到 Inputs / Atomic Steps / Outputgrep 一下 endpoints_whitelist.yaml 确认存在$.data.bvid)按 recipe 的 extract 列绑定为变量,传给下游端点反例(agent 不要这么做):
endpoints_whitelist.yaml(大文件,浪费上下文)extract 列,自己猜 json_pathweb_get_trending_videos 按地区拉趋势榜 → 取 video_id → 链式调 web_v2_get_video_info_v2 取标题、时长、播放、互动;对 Top 视频再 web_v2_get_video_comments 抽取观众反馈关键词web_v2_get_shorts_search_v2 关键词搜索 → 取 video_id → web_v2_get_video_info_v2 取播放与互动;并行 web_v2_get_channel_shorts 抓取头部 Shorts 频道全部短视频web_get_channel_id 解析 @handle → web_v2_get_channel_description 取频道概况 → web_v2_get_channel_videos + web_v2_get_channel_shorts + web_v2_get_channel_community_posts 全量采集 → 抽样视频 web_v2_get_video_comments 看观众结构web_v2_get_channel_videos 翻页采集 video_id → web_v2_get_video_captions 拉原始字幕 → 失败时降级 web_get_video_info 拿 subtitle_url,再 web_get_video_subtitles 指定 target_lang 翻译maxhub-youtube/
├── SKILL.md # Skill 定义与使用文档(本文件)
├── README.md # 英文项目说明
├── README_CN.md # 中文项目说明
├── _meta.json # 版本元信息(version: 3.7.2)
└── references/
├── endpoints_whitelist.yaml # 37 端点路径硬白名单 + Pre-call 4 步自检协议
├── param-mappings.md # 中枢索引(全局红线 + 字段流字典 + 错误处理 + Web/V2 差异)
├── video.md # 视频域:详情/Streams/Captions/相关/趋势(13 端点)
├── channel.md # 频道域:信息/视频/Shorts/社区帖/ID互转(12 端点)
├── search.md # 搜索域:综合/Shorts/频道/建议词(7 端点)
└── comments.md # 评论域:视频评论/回复/帖子评论(5 端点)
| 组件 | 技术 | 说明 |
|---|---|---|
| ------ | ------ | ------ |
| 调用方式 | curl + Bearer Token | HTTP GET 请求,参数通过 query string 传递 |
| 数据接口 | MaxHub API | https://www.aconfig.cn/api/v1/youtube/{web,web_v2}/*,通过 MAXHUB_API_KEY 鉴权 |
| 路径校验 | YAML 硬白名单 | endpoints_whitelist.yaml 提供 37 端点的逐字符校验 + 4 步 Pre-call 协议 |
| 错误处理 | 决策表 + 自检清单 | HTTP 状态码权威定义 + 防臆造自检(A/B 双轨)+ Web↔Web V2 替换矩阵 |
| 输出格式 | JSON Standard MaxHub Response | {code, message, message_zh, data, cache_url} |
| 更新通道 | SkillHub / ClawHub / GitHub | 国内 ⭐⭐⭐ SkillHub(腾讯云 CDN)/ 国际 ⭐⭐⭐ ClawHub / 降级 GitHub |
| 领域 | 端点数 | Reference 文件 |
|---|---|---|
| ------ | -------- | --------------- |
| 视频(Video / Streams / Captions) | 13 | video.md |
| 频道(Channel / Shorts / Community) | 12 | channel.md |
| 搜索(Search / Suggestions) | 7 | search.md |
| 评论(Comments / Post Replies) | 5 | comments.md |
| 合计 | 37 | — |
search_query vs keyword),杜绝 Agent 跨版本套用共 10 个版本