---
name: youtube-upload
description: Upload a video to YouTube Shorts using the browser. Handles file selection, title/description/tags, visibility settings, and post-upload URL retrieval.
metadata:
  {
    "openclaw":
      {
        "emoji": "▶️",
        "always": false,
      },
  }
---

# YouTube Upload 技能

Use this skill when:
- A video has been generated (via siliconflow-video-gen or other means) and needs publishing to YouTube
- You need to upload an MP4 to YouTube Shorts with proper metadata
- You need to set the video as unlisted or public

**Prerequisites**: Browser session must be logged in to YouTube Studio (studio.youtube.com).

---

## Cookie Warmup

Navigate to `https://studio.youtube.com` first. Confirm the channel dashboard loads (not a login page).

---

## Workflow: Upload Video

```
1. Navigate to https://www.youtube.com/upload
   (Alternative: click the camcorder "Create" icon in YouTube Studio)

2. Wait for the upload dialog to open
   - timeout: 15000ms

3. Find the file input element and provide the video file path:
   - Look for the file picker input (hidden input[type=file] inside ytcp-uploads-file-picker)
   - Send the absolute file path to the input
   - timeout: 10000ms (file path injection itself is fast)

4. Wait for upload progress to complete
   - Poll the progress indicator every 10 seconds using snapshot
   - Do NOT proceed until progress bar disappears or shows "Processing"
   - timeout: 300000ms (5 minutes) — large videos can take several minutes
   - If still uploading after 5 minutes, inform the user and wait for their reply

5. Fill in the Title:
   - Click the title field (first text area, id="textbox")
   - Wait 1 second after click before typing
   - Clear existing text, then type the video title (max 100 characters)
   - timeout: 10000ms

6. Fill in the Description:
   - Click the description field (last text area)
   - Wait 1 second after click before typing
   - Clear existing text, then type the description + hashtags
   - timeout: 10000ms

7. Set "Made for kids":
   - Select "No, it's not made for kids" unless explicitly required

8. Click "Next" three times (Details → Video elements → Checks → Visibility)
   - Wait 2 seconds between each "Next" click for the page transition to settle
   - timeout per click: 15000ms

9. On the Visibility page, set visibility:
   - "Public" — for immediate publishing
   - "Unlisted" — for draft/review before sharing
   - "Scheduled" — to set a publish date/time

10. Click the "Publish" (or "Save") button
    - timeout: 15000ms

11. Wait for confirmation:
    - Poll every 3 seconds for dialog close or "Your video has been published" message
    - timeout: 30000ms

12. Retrieve the video URL:
    - Navigate to https://studio.youtube.com/channel/<channel_id>/videos/short
    - Find the first video row
    - Extract the video URL (format: https://youtube.com/shorts/<video_id>)
    - Report the URL to the user
```

---

## Getting the Channel ID

If the channel ID is not known:
```
1. Navigate to https://studio.youtube.com
2. The URL changes to https://studio.youtube.com/channel/<channel_id>
3. Extract the channel_id from the URL
```

---

## Handling Metadata

Use the `.json` file generated by `shorts-compose`:

```
title       → YouTube video title (trim to 100 chars)
description → Video description (add tags as #hashtags at the end)
tags        → Add as #hashtag1 #hashtag2 at the end of description
```

Example description format:
```
AI工具如何改变你的工作方式，本视频介绍了3个高效AI工具...

#AI工具 #效率提升 #科技 #shorts
```

---

## Visibility Guide

| Setting | Use Case |
|---------|----------|
| `Public` | Ready to publish immediately |
| `Unlisted` | Share with specific people via link (no public search) |
| `Scheduled` | Set a future publish time for optimal reach |
| `Private` | Save draft, not visible to anyone |

---

## Error Handling

| Situation | Action |
|-----------|--------|
| Login page appears | Session expired — inform user to re-login |
| File not found | Verify the absolute path in the metadata JSON |
| Upload stuck | Wait up to 5 minutes; check file size (YouTube limit: 256GB, 12 hours) |
| Copyright claim during processing | Report to user — they decide whether to proceed |
| "Video is being processed" (not Shorts) | Video may not meet Shorts criteria (must be ≤60s, 9:16) |
| Title too long | Trim to 100 characters |

---

## Notes

- YouTube Shorts requires: ≤ 60 seconds duration, 9:16 aspect ratio preferred
- `shorts-compose` outputs compliant 9:16 videos by default
- After upload, YouTube processes the video (1–5 minutes) before it appears publicly
- Always report the final video URL when done
