OA0 = Omni AI 0
OA0 是一个探索 AI 的论坛
现在注册
已注册用户请  登录
OA0  ›  技能包  ›  youtube-studio:面向 Clawdbot 的全面 YouTube 频道管理技能

youtube-studio:面向 Clawdbot 的全面 YouTube 频道管理技能

 
  openclaw ·  2026-02-26 01:43:37 · 2 次点击  · 0 条评论  

YouTube Studio 技能

为 Clawdbot 提供的综合 YouTube 频道管理技能。监控分析数据、上传视频、管理评论并生成内容创意。

概述

youtube-studio 提供功能全面的 YouTube 频道管理:
- 实时频道统计与分析
- 支持元数据和定时发布的视频上传
- 评论监控与 AI 驱动的回复建议
- 基于趋势和细分领域的内容创意生成
- 速率限制与错误恢复
- OAuth 2.0 身份验证

设置

1. YouTube Data API v3 凭证

获取 API 密钥和 OAuth 凭证

  1. 访问 Google Cloud Console
  2. 创建一个新项目(例如:"Clawdbot YouTube Studio")
  3. 启用 YouTube Data API v3
    • 搜索 "YouTube Data API v3"
    • 点击 "启用"
  4. 创建 OAuth 2.0 凭证:
    • 进入 "凭证"
    • 点击 "创建凭证" → "OAuth 客户端 ID"
    • 选择 "桌面应用"
    • 下载 JSON 文件(保存为 credentials.json
  5. 创建 API 密钥(用于公开请求):
    • 点击 "创建凭证" → "API 密钥"
    • 复制密钥

文件结构

~/.clawd-youtube/
├── credentials.json       # OAuth 凭证(来自步骤 4)
├── tokens.json           # 首次 OAuth 流程后生成
└── config.env            # API 密钥和设置

2. 环境设置

.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

3. OAuth 2.0 流程

该技能在首次运行时自动处理 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.json
  • 重新运行 youtube-studio auth
  • 检查 credentials.json 是否有效

配额超限

  • 检查 youtube-studio quota-status
  • 等待 UTC 午夜(配额重置)
  • 考虑在 Cloud Console 中提高 API 配额

上传失败

  • 检查文件是否存在且可读
  • 验证文件格式是否受支持
  • 检查视频是否违反 YouTube 政策
  • 使用 --dry-run 先测试元数据

评论不显示

  • 确保频道已使用所有者账户认证
  • 检查评论审核设置
  • 验证 YOUTUBE_CHANNEL_ID 是否与你的频道匹配

API 参考

核心方法

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"

限制

  • YouTube API 配额:每天 1M 单位(足够约 600 次上传/天)
  • 视频必须 <256GB
  • 标题限制为 100 个字符
  • 描述限制为 5,000 个字符
  • 评论回复限制为 10,000 个字符
  • 暂不支持直播流管理

未来增强

  • [ ] 直播流监控和聊天审核
  • [ ] 播放列表自动化
  • [ ] 字幕生成(使用 Whisper)
  • [ ] 使用 CV 优化缩略图
  • [ ] 分析仪表板
  • [ ] 多频道支持
  • [ ] 计划内容日历

许可证

MIT - 可在 Clawdbot 生态系统内自由使用

支持

遇到问题?请检查:
1. ~/.clawd-youtube/logs/ 中的调试输出
2. 凭证有效性:youtube-studio auth
3. API 配额:youtube-studio quota-status
4. 网络:Ping Google API 服务器

2 次点击  ∙  0 人收藏  
登录后收藏  
目前尚无回复
0 条回复
About   ·   Help   ·    
OA0 - Omni AI 0 一个探索 AI 的社区
沪ICP备2024103595号-2
Developed with Cursor