youtube-publisher
Upload and fully manage YouTube videos and live events: metadata, thumbnails, captions, playlists, scheduled broadcasts, encoder streams, binding, lifecycle transitions, and cleanup.
wlzh · 已有 AI 审核记录
安装与使用
运行命令前先阅读来源与依赖说明。复制命令不会自动安装或执行。
npx skills add wlzh/skills --skill youtube-publisher技能说明
name: youtube-publisher description: "Upload and fully manage YouTube videos and live events: metadata, thumbnails, captions, playlists, scheduled broadcasts, encoder streams, binding, lifecycle transitions, and cleanup." version: 1.7.0 setup_complete: true setup: "./SETUP.md" changelog: "v1.7.0: full YouTube Live lifecycle with writable-field-safe updates, fail-closed ambiguous upload recovery, non-destructive caption upsert, OAuth CSRF protection, secret-safe output, explicit destructive-operation guards, regression tests, and CI. Full history: references/CHANGELOG.md."
🔴 Strict Execution Rule (Highest Priority)
Every instruction, step, and check in this SKILL.md must be followed exactly as written — no deviations allowed.
- Scripts must be actually executed: The
youtube-upload.tsscript must be run with all required parameters. Do not simulate or manually construct API calls. - Steps must not be skipped or merged: Execute authentication, metadata sanitization, and upload in the defined order. Each step must succeed before the next begins.
- Checks must not be omitted: All metadata validation (title ≤100 chars, description ≤5000 chars, tags ≤500 chars) and upload verification must be fully executed.
- Config must be read from files: OAuth credentials and default settings must be read from the configured files. Do not hardcode.
YouTube Publisher
First time? If
setup_complete: falseabove, run./SETUP.mdfirst, then setsetup_complete: true.
Upload videos to YouTube with full metadata control.
Live broadcasts and encoder streams
Use youtube-live.ts to list, inspect, schedule, update, bind, transition, and delete
YouTube Live broadcasts and encoder streams. Mutating commands support --dry-run;
destructive deletion, live/completed transitions, and stream-key disclosure require
explicit --yes. Stream keys are redacted from ordinary output.
The safe default is one dedicated named encoder stream per independent show/event.
Intentional reuse across active or upcoming broadcasts requires --allow-shared-stream.
Read references/live-streaming.md before operating a live
event. Scheduled timestamps must include an explicit timezone (Z or ±HH:MM).
The skill passes --inherit-previous before creation unless the user requests a clean
profile. The raw CLI remains deterministic and offline without that explicit flag.
An interrupted video insert is never retried inside youtube-upload.ts. Recovery must
identify exactly one recent same-title video with a verified non-zero duration. Persistent
P0D exits 42 with PERSISTENT_P0D_VIDEO_ID; unavailable or inconclusive inspection
exits 43 with AMBIGUOUS_UPLOAD_VIDEO_ID. Inspect the channel before another insert.
Caption recovery updates one exact language/name track in place or inserts a new track. It never deletes an existing caption before the replacement upload succeeds.
Metadata sanitization
>in title/description is automatically rewritten to》<in title/description is automatically rewritten to《- Use this when YouTube rejects metadata because of special characters
Quick Start
cd ~/.claude/skills/youtube-publisher/scripts
# First time: authenticate
npx ts-node youtube-upload.ts --auth
# Upload video
npx ts-node youtube-upload.ts \
--video /path/to/video.mp4 \
--title "My Awesome Video" \
--description "Check out this amazing content!" \
--tags "tech,ai,tutorial" \
--privacy unlisted
# Upload as YouTube Short (vertical video)
npx ts-node youtube-upload.ts \
--video /path/to/short.mp4 \
--title "Quick Tip #Shorts" \
--description "A quick tip for you!" \
--privacy public \
--short
Options
| Option | Short | Description |
|---|---|---|
--video | -v | Video file path (required) |
--title | -t | Video title (required) |
--description | -d | Video description |
--tags | Comma-separated tags | |
--privacy | -p | Privacy: public, unlisted, private (default: unlisted) |
--category | -c | Category ID (default: 22 = People & Blogs) |
--thumbnail | Custom thumbnail image (local path or URL) | |
--subtitles | Subtitle file path (SRT/VTT) | |
--subtitle-lang | Subtitle language code (default: zh) | |
--subtitle-name | Subtitle display name (default: 中文) | |
--playlist | Add to playlist ID | |
--short | Mark as YouTube Short | |
--auth | Run OAuth2 authentication flow | |
--dry-run | Preview without uploading |
Category IDs
| ID | Category |
|---|---|
| 1 | Film & Animation |
| 2 | Autos & Vehicles |
| 10 | Music |
| 15 | Pets & Animals |
| 17 | Sports |
| 19 | Travel & Events |
| 20 | Gaming |
| 22 | People & Blogs |
| 23 | Comedy |
| 24 | Entertainment |
| 25 | News & Politics |
| 26 | Howto & Style |
| 27 | Education |
| 28 | Science & Technology |
Authentication
First-time setup requires OAuth2 authentication:
- Run
npx ts-node youtube-upload.ts --auth - Browser opens Google login
- Grant permissions to upload videos
- Token is saved to
.youtube-token.json
Token refreshes automatically. Re-run --auth if expired.
Environment
Create scripts/.env:
YOUTUBE_CLIENT_ID=your_client_id
YOUTUBE_CLIENT_SECRET=your_client_secret
Get credentials from Google Cloud Console:
- Create project at console.cloud.google.com
- Enable YouTube Data API v3
- Create OAuth2 credentials (Desktop app)
- Download and extract client_id & client_secret
Examples
Upload Tutorial Video
npx ts-node youtube-upload.ts \
-v tutorial.mp4 \
-t "How to Use Claude Code - Complete Guide" \
-d "Learn everything about Claude Code in this comprehensive tutorial.
Timestamps:
00:00 Introduction
02:30 Getting Started
05:00 Advanced Features
#ClaudeCode #AI #Tutorial" \
--tags "claude code,ai,tutorial,anthropic,coding" \
--category 28 \
--privacy public
阅读完整来源 ↗