YouTube Upload Skill
This skill allows you to securely upload videos to YouTube via the official API, bypassing the need for fragile browser automation.
Prerequisites
- 1. The Google API Python Client and OAuth libraries must be installed:
pip3 install google-api-python-client google-auth-oauthlib google-auth-httplib2
- 2. A
client_secret.json file is required. The user must generate an OAuth 2.0 Client ID (Desktop App) from the Google Cloud Console with the YouTube Data API v3 enabled.
Usage
Use the provided Python script to upload the video:
CODEBLOCK1
First Run (Authentication)
On the very first run, the script will output a URL or open a browser window for the user to authenticate and grant permission to their YouTube account. Instruct the user to complete the login flow. Once approved, a
token.pickle file is generated locally, and subsequent uploads will run silently.
Troubleshooting
- - Token Expired / Revoked: If the token becomes invalid, delete
token.pickle and re-run to trigger the auth flow again. - Quota Exceeded: The YouTube API has a daily upload quota. If this is hit, the user must wait until the quota resets.
YouTube 上传技能
该技能允许您通过官方 API 安全地将视频上传到 YouTube,无需使用脆弱的浏览器自动化。
前提条件
- 1. 必须安装 Google API Python 客户端和 OAuth 库:
bash
pip3 install google-api-python-client google-auth-oauthlib google-auth-httplib2
- 2. 需要 client_secret.json 文件。用户必须从 Google Cloud Console 生成一个 OAuth 2.0 客户端 ID(桌面应用),并启用 YouTube Data API v3。
使用方法
使用提供的 Python 脚本上传视频:
bash
python3 scripts/upload.py \
--file /path/to/video.mp4 \
--title 我的视频标题 \
--description 我的视频描述 \
--privacy unlisted \
--secrets /path/to/client_secret.json
首次运行(身份验证)
首次运行时,脚本会输出一个 URL 或打开浏览器窗口,让用户进行身份验证并授权访问其 YouTube 账户。指导用户完成登录流程。授权后,会在本地生成 token.pickle 文件,后续上传将静默运行。
故障排除
- - 令牌过期/撤销: 如果令牌失效,请删除 token.pickle 并重新运行以触发身份验证流程。
- 配额超出: YouTube API 有每日上传配额限制。如果达到配额上限,用户必须等待配额重置。