为 Clawdbot 提供的综合 YouTube 频道管理技能。监控分析数据、上传视频、管理评论并生成内容创意。
youtube-studio 提供功能全面的 YouTube 频道管理:
- 实时频道统计与分析
- 支持元数据和定时发布的视频上传
- 评论监控与 AI 驱动的回复建议
- 基于趋势和细分领域的内容创意生成
- 速率限制与错误恢复
- OAuth 2.0 身份验证
credentials.json)~/.clawd-youtube/
├── credentials.json # OAuth 凭证(来自步骤 4)
├── tokens.json # 首次 OAuth 流程后生成
└── config.env # API 密钥和设置
将 .env.example 复制到 ~/.clawd-youtube/config.env:
# YouTube API
YOUTUBE_API_KEY=你的_api_密钥
YOUTUBE_CLIENT_ID=你的_client_id.apps.googleusercontent.com
YOUTUBE_CLIENT_SECRET=你的_client_secret
YOUTUBE_REDIRECT_URI=http://localhost:8888/oauth2callback
# 频道设置
YOUTUBE_CHANNEL_ID=UCxxxxxxxxxxxxxx
YOUTUBE_CHANNEL_NAME=你的频道名称
# AI 模型(用于建议和回复)
AI_MODEL=openrouter/anthropic/claude-haiku-4.5
AI_API_KEY=你的_api_密钥
# 速率限制
API_QUOTA_PER_DAY=1000000
BATCH_SIZE=50
# 日志记录
LOG_LEVEL=info
LOG_DIR=./logs
该技能在首次运行时自动处理 OAuth:
youtube-studio auth
# 打开浏览器进行 Google 登录
# 交换授权码以获取刷新令牌
# 将令牌保存到 tokens.json
后续运行 将使用保存的刷新令牌(无需重新认证)。
youtube-studio stats
youtube-studio stats --days 7 # 最近 7 天
youtube-studio stats --json # JSON 输出
输出:
- 总观看次数、订阅者、观看时长
- 近期视频表现(前 5 名)
- 增长趋势
- 互动指标(视频平均观看量、点赞、评论数)
youtube-studio upload \
--file video.mp4 \
--title "我的灵修系列 #5" \
--description "和我一起开始另一段..." \
--tags "devotional,faith,inspiration" \
--privacy public \
--schedule "2024-01-15T10:00:00Z"
选项:
- --file (必需):视频文件路径(mp4, mov, avi, mkv)
- --title (必需):视频标题
- --description:完整描述(支持 Markdown)
- --tags:逗号分隔的标签(最多 500 字符)
- --privacy:公开、不公开、私享(默认:不公开)
- --thumbnail:自定义缩略图路径
- --playlist:按名称添加到现有播放列表
- --schedule:计划上传的 ISO 8601 日期时间
- --category:视频类别(音乐、人物等)
youtube-studio comments
youtube-studio comments --video-id xxxxx # 特定视频
youtube-studio comments --unread # 仅未读评论
youtube-studio comments --limit 50 # 限制结果数量
youtube-studio comments --json # JSON 输出
youtube-studio reply \
--comment-id Qmxxxxxxxxxxxxxxxx \
--text "感谢观看!" \
--suggest # 先显示 AI 建议
标志:
- --suggest:回复前生成 3 条回复建议
- --template:使用预设模板(感谢、教育、推广)
- --dry-run:预览而不发送
youtube-studio ideas
youtube-studio ideas --niche devotional
youtube-studio ideas --trending # 基于 YouTube 趋势
youtube-studio ideas --json # JSON 输出
youtube-studio ideas --count 10 # 创意数量
输出:
- 标题建议
- 描述钩子
- 目标受众分析
- SEO 关键词
- 预估搜索量
- 缩略图创意
YouTube API 配额:
- 每日配额: 1,000,000 单位(默认)
- 各方法成本:
- channels.list:1 单位
- videos.list:1 单位
- videos.insert:1,600 单位(上传)
- commentThreads.list:1 单位
- comments.insert:1 单位
技能处理:
- 自动配额跟踪
- 请求批处理
- 403 错误时的指数退避重试
- 每日重置监控
- 配额使用超过 80% 时发出警报
youtube-studio quota-status # 检查剩余配额
| 错误 | 处理方式 |
|---|---|
401 未授权 |
自动刷新 OAuth 令牌 |
403 配额超限 |
等待至次日,显示警报 |
429 速率限制 |
指数退避(1秒,2秒,4秒...) |
500 服务器错误 |
最多重试 3 次 |
| 网络超时 | 使用断路器优雅重试 |
| 上传中断 | 从最后一个数据块恢复 |
youtube-studio/
├── SKILL.md # 本文档
├── README.md # 用户指南
├── scripts/
│ ├── youtube-studio.js # 主入口点 & CLI
│ ├── channel-analytics.js # 统计与分析
│ ├── video-uploader.js # 视频上传逻辑
│ ├── comment-manager.js # 评论操作
│ ├── content-ideas.js # 创意生成
│ ├── auth-handler.js # OAuth 流程
│ ├── api-client.js # 配额感知的 API 包装器
│ └── utils.js # 辅助函数
├── config/
│ ├── templates.json # 描述模板、标签
│ └── niche-prompts.json # 创意提示模板
├── .env.example # 环境变量模板
├── package.json # 依赖项
└── logs/ # 运行时日志
{
"devoted_journey": {
"title": "每日灵修 - {topic}",
"description": "🙏 {hook}\n\n{body}\n\n⏱️ 时间戳:\n{timestamps}\n\n📖 经文:{reference}\n\n💬 反思:{reflection_question}",
"tags": ["devotional", "faith", "scripture", "spiritual"]
}
}
grateful:感谢订阅者的支持educational:深入解释概念promotional:链接到相关视频engagement:提出后续问题{
"googleapis": "^120.0.0",
"google-auth-library": "^9.0.0",
"axios": "^1.6.0",
"express": "^4.18.0"
}
tokens.jsonyoutube-studio authcredentials.json 是否有效youtube-studio quota-status--dry-run 先测试元数据YOUTUBE_CHANNEL_ID 是否与你的频道匹配authenticateOAuth()初始化 OAuth 2.0 流程。返回刷新令牌。
getChannelStats(options = {})days:回溯天数(默认:30){ views, subscribers, watchHours, videos, topVideos[] }uploadVideo(metadata, filePath, options = {})metadata:标题、描述、标签、隐私设置filePath:视频文件路径{ videoId, status, scheduledTime }listComments(videoId = null, options = {})videoId:特定视频或 null 表示全部unread:布尔值,仅获取未读评论{ comments[], total, pageToken }replyToComment(commentId, text, options = {})template:使用预设模板suggestFirst:获取 AI 建议{ replyId, text }generateVideoIdeas(options = {})niche:频道细分领域/类别trending:包含趋势话题{ ideas[], keywords[], thumbnail_prompts[] }# 检查统计
youtube-studio stats --days 1
# 查看评论并获取建议
youtube-studio comments --limit 20 --suggest
# 生成新视频创意
youtube-studio ideas --trending --count 5
# 在计划上传前检查配额
youtube-studio quota-status
#!/bin/bash
youtube-studio upload \
--file ~/Videos/devotional.mp4 \
--title "每日灵修 - $(date +%Y-%m-%d)" \
--description "$(cat description.txt)" \
--schedule "$(date -d '明天 10:00' -Iseconds)" \
--tags "devotional,daily,faith"
MIT - 可在 Clawdbot 生态系统内自由使用
遇到问题?请检查:
1. ~/.clawd-youtube/logs/ 中的调试输出
2. 凭证有效性:youtube-studio auth
3. API 配额:youtube-studio quota-status
4. 网络:Ping Google API 服务器