Youtube Upload
社区Uploads a video to YouTube using the official YouTube Data API v3 and OAuth 2.0. Use this skill when the user asks to upload a video to YouTube. It supports titles, descriptions, privacy settings (public, private, unlisted), and large file chunking. Requires a Google Cloud 'client_secret.json' file.
AkshayDev v1.0.0
安装命令
$ cow skill install youtube-upload
终端输入或发送给 CowAgent 一键安装
内容创作
Uploads a video to YouTube using the official YouTube Data API v3 and OAuth 2.0. Use this skill when the user asks to upload a video to YouTube. It supports titles, descriptions, privacy settings (public, private, unlisted), and large file chunking. Requires a Google Cloud 'client_secret.json' file.
# OpenClaw YouTube Upload Skill
A specialized skill for OpenClaw that enables AI agents to securely upload videos to YouTube using the official YouTube Data API v3 and OAuth 2.0.
This skill bypasses the need for fragile browser automation (like Playwright/Puppeteer) by utilizing a robust Python script under the hood, supporting large file uploads (chunking), titles, descriptions, and privacy settings.
## Features
- **Reliable Uploads:** Uses `google-api-python-client` with resumable uploads to handle large video files without crashing.
- **Agent Ready:** Packaged as an OpenClaw `.skill`, allowing agents like Claude Code or Gemini to seamlessly trigger YouTube uploads.
- **Customizable:** Agents can pass `--title`, `--description`, and `--privacy` (public/private/unlisted) arguments.
## Prerequisites
1. **Google Cloud Credentials:**
You must generate an OAuth 2.0 Client ID (Desktop App) from the Google Cloud Console with the **YouTube Data API v3** enabled.
Save the downloaded JSON file as `client_secret.json` in the root of the skill folder.
2. **Python Dependencies:**
The host machine needs Python 3 and the following packages installed:
```bash
pip3 install google-api-python-client google-auth-oauthlib google-auth-httplib2
```
## Installation for OpenClaw
To install this skill locally in your OpenClaw environment:
```bash
openclaw skills install <path_to_skill_folder_or_.skill_file>
```
## First-time Authentication
On the very first run, the script requires user interaction. The agent will execute the script, which will generate an OAuth URL. The user must click the URL, authenticate with their Google account, and grant YouTube upload permissions.
Once approved, a `token.pickle` file is generated locally, and all subsequent uploads will run silently and automatically.
## Usage (CLI / Internal)
Agents will internally call the script like this:
```bash
python3 scripts/upload.py \
--file "/path/to/video.mp4" \
--title "My Awesome Video" \
--description "Description goes here" \
--privacy "unlisted" \
--secrets "client_secret.json"
```
## Publishing to ClawdHub
*This repository is intended to be published on ClawdHub. Contributions and improvements are welcome.*
---
name: youtube-upload
description: "Uploads a video to YouTube using the official YouTube Data API v3 and OAuth 2.0. Use this skill when the user asks to upload a video to YouTube. It supports titles, descriptions, privacy settings (public, private, unlisted), and large file chunking. Requires a Google Cloud 'client_secret.json' file."
metadata:
openclaw:
emoji: "📺"
requires:
bins: ["python3", "pip3"]
---
# 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:
```bash
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:
```bash
python3 scripts/upload.py \
--file "/path/to/video.mp4" \
--title "My Video Title" \
--description "My Video Description" \
--privacy "unlisted" \
--secrets "/path/to/client_secret.json"
```
### 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.
{
"ownerId": "kn77x6ehgv5pkayjpnq3v6m0x1801f6m",
"slug": "youtube-upload",
"version": "1.0.0",
"publishedAt": 1772303967933
} import argparse
import os
import sys
import pickle
from googleapiclient.discovery import build
from googleapiclient.http import MediaFileUpload
from google_auth_oauthlib.flow import InstalledAppFlow
from google.auth.transport.requests import Request
# If modifying these scopes, delete the file token.pickle.
SCOPES = ['https://www.googleapis.com/auth/youtube.upload']
def get_authenticated_service(client_secret_file):
creds = None
token_file = 'token.pickle'
if os.path.exists(token_file):
with open(token_file, 'rb') as token:
creds = pickle.load(token)
if not creds or not creds.valid:
if creds and creds.expired and creds.refresh_token:
creds.refresh(Request())
else:
if not os.path.exists(client_secret_file):
print(f"Error: Client secret file not found at {client_secret_file}")
sys.exit(1)
flow = InstalledAppFlow.from_client_secrets_file(client_secret_file, SCOPES)
creds = flow.run_local_server(port=0)
with open(token_file, 'wb') as token:
pickle.dump(creds, token)
return build('youtube', 'v3', credentials=creds)
def upload_video(youtube, file, title, description, privacy_status):
body = {
'snippet': {
'title': title,
'description': description,
'categoryId': '22' # People & Blogs
},
'status': {
'privacyStatus': privacy_status,
'selfDeclaredMadeForKids': False
}
}
# Resumable upload for large files
insert_request = youtube.videos().insert(
part=','.join(body.keys()),
body=body,
media_body=MediaFileUpload(file, chunksize=-1, resumable=True)
)
print(f"Starting upload for {file}...")
response = None
while response is None:
status, response = insert_request.next_chunk()
if status:
print(f"Uploaded {int(status.progress() * 100)}%")
print("\nUpload Complete!")
video_id = response.get('id')
print(f"Video ID: {video_id}")
print(f"Link: https://youtu.be/{video_id}")
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Upload a video to YouTube.')
parser.add_argument('--file', required=True, help='Path to the video file.')
parser.add_argument('--title', required=True, help='Title of the video.')
parser.add_argument('--description', default='', help='Description of the video.')
parser.add_argument('--privacy', default='unlisted', choices=['public', 'private', 'unlisted'], help='Privacy status.')
parser.add_argument('--secrets', default='client_secret.json', help='Path to the client_secret.json file.')
args = parser.parse_args()
if not os.path.exists(args.file):
print(f"Error: Video file not found at {args.file}")
sys.exit(1)
youtube_service = get_authenticated_service(args.secrets)
upload_video(youtube_service, args.file, args.title, args.description, args.privacy)
## Description: <br>
Uploads a video to YouTube using the official YouTube Data API v3 and OAuth 2.0, with support for titles, descriptions, privacy settings, and large file chunking. <br>
This skill is ready for commercial/non-commercial use. <br>
## Publisher: <br>
[BrOrlandi](https://clawhub.ai/user/BrOrlandi) <br>
### License/Terms of Use: <br>
## Use Case: <br>
Developers and external agent users use this skill to upload local video files to YouTube through the official API after configuring Google Cloud OAuth credentials. It is suited for agent-assisted publishing workflows that need title, description, privacy, and resumable upload support. <br>
### Deployment Geography for Use: <br>
Global <br>
## Known Risks and Mitigations: <br>
Risk: The skill requires YouTube upload permission through Google OAuth. <br>
Mitigation: Install and run it only when that permission is acceptable, and revoke the Google OAuth grant when it is no longer needed. <br>
Risk: OAuth client secrets and generated tokens can allow access if exposed. <br>
Mitigation: Keep client_secret.json and token.pickle private, avoid committing or sharing them, and delete token.pickle when resetting access. <br>
Risk: An unintended file or privacy setting could publish content incorrectly. <br>
Mitigation: Confirm the target video path, title, description, and privacy setting before each upload. <br>
## Reference(s): <br>
- [ClawHub skill page](https://clawhub.ai/BrOrlandi/youtube-upload) <br>
## Skill Output: <br>
**Output Type(s):** [Shell commands, Configuration, API calls, Guidance] <br>
**Output Format:** [Markdown with inline bash code blocks and command output] <br>
**Output Parameters:** [1D] <br>
**Other Properties Related to Output:** [Requires Python 3, pip, Google API Python libraries, a Google Cloud OAuth client secret file, and local user authentication on first run.] <br>
## Skill Version(s): <br>
1.0.0 (source: server release metadata and user changelog) <br>
## Ethical Considerations: <br>
Users should evaluate whether this skill is appropriate for their environment, review any generated or modified files before relying on them, and apply their organization's safety, security, and compliance requirements before deployment. <br>