TL;DR
- 本文解決:每次上傳 YouTube 都要打開瀏覽器、貼一次標題、貼一次描述、選播放清單、設隱私、上傳字幕——同樣動作做 100 次
- 推薦給:自己會剪片、有頻道、習慣用 Claude Code 的工程師 / 創作者
- 讀完你會知道:怎麼裝 yc-plugin、第一次怎麼設 OAuth、怎麼一行指令上傳影片、怎麼把這個工具分享給朋友用同一份 credentials
這篇是 yc-plugin 的官方介紹文。Plugin 本身只做一件事——/yc-plugin:youtube-upload <影片路徑> 一條指令上傳到 YouTube——但這條指令背後是 OAuth + YouTube Data API v3 + resumable upload + 字幕自動偵測 + 排程發布的整套自動化。
我自己每週固定上幾個影片,原本流程是:開 YouTube Studio、拖檔案、等上傳、貼 metadata、上字幕、選播放清單。一次 5-10 分鐘,做 5 次就 30 分鐘沒了。改用這個 plugin 之後,從 5 分鐘變 30 秒——剩下的事情 Claude Code 邊問邊幫我填。
---
📌 目錄
---
🎯 這個 Plugin 解決什麼問題
痛點 1:YouTube Studio 點擊地獄
每支影片進來,你要點 14 次以上才能發布:拖檔 → 等預覽 → 改標題 → 貼描述 → 選縮圖 → 改 tags → 選播放清單 → 上字幕 → 設語言 → 設「兒童內容」開關 → 排程 → 預覽 → 確認 → 發布。
99% 都是同樣的內容——你的固定 hashtag、固定 outro、固定 disclaimer。
痛點 2:上字幕特別煩
字幕檔(.srt / .vtt)通常跟影片同目錄、檔名一樣。YouTube Studio 不會自動帶——你還是得手動「Subtitles → Add subtitle → Upload file」每一支重來。
痛點 3:CLI 跟工作流脫節
你已經在 terminal、已經在剪片資料夾、已經在 Claude Code。為什麼上傳還要切回瀏覽器?
解法
/yc-plugin:youtube-upload 一條指令把上面 14 個點擊壓縮成:
從拖檔到拿到 URL,30 秒。
---
⚖️ yc-plugin vs 其他上傳方式
| 功能 | YouTube Studio | youtube-upload (CLI) | yt-dlp + 自製 script | yc-plugin |
|---|---|---|---|---|
| 一行指令上傳 | ✗ | ✓ | △(要自己寫) | ✓ |
| 字幕自動偵測 | ✗ | ✗ | △ | ✓ |
| 播放清單自動建 | △ | ✗ | △ | ✓ |
| 排程發布 | ✓ | ✗ | △ | ✓ |
| 縮圖支援 | ✓ | △ | △ | ✓ |
| OAuth 一次設定終身用 | ✗ | ✓ | ✓ | ✓ |
| 跟 Claude Code 整合 | ✗ | ✗ | ✗ | ✓ |
| 跨平台(Mac/Linux/Win) | ✓ | △ | △ | ✓ |
| dry-run 預覽 metadata | ✗ | ✗ | ✗ | ✓ |
| 跟朋友共享 credentials | ✗ | △ | △ | ✓(加密 zip) |
google-api-python-client,同步官方 API 變更。
為什麼不用 yt-dlp? yt-dlp 是下載工具,不做上傳。
---
🛠️ 從 0 開始安裝
Prerequisites
| 項目 | 用途 | 怎麼裝 / 確認 |
|---|---|---|
| Claude Code 最新版 | 跑 plugin 系統 | claude --version,沒裝走 官方 quickstart |
| Python 3.10+ | 跑上傳腳本 | python3 --version,macOS brew install python@3.12、Ubuntu sudo apt install python3 python3-pip |
| Git | clone marketplace | git --version |
| Google 帳號 | 建 OAuth credential | 你自己已有的 Gmail 即可 |
| YouTube 頻道 | 上傳目標 | 在 studio.youtube.com 建立過頻道 |
claude --version # 應該看到 Claude Code 1.x 版本號
python3 --version # 應該看到 Python 3.10 以上
git --version # 應該看到 Git 2.x
安裝(一次性)
打開 Claude Code,下:
/plugin marketplace add yanchen184/yc-plugin
/plugin install yc-plugin@yc-plugin
第一條把我的 marketplace 加進來,第二條從 marketplace 裝 plugin 本體。
裝完 Claude Code 會跑 SessionStart hook 自動裝 Python 依賴(google-api-python-client、google-auth-oauthlib 那幾個),第一次大概 30 秒。
驗證裝好:
/yc-plugin:youtube-setup --show
預期看到:
client_secret.json: (missing) ← 第一次裝就是 missing,下一段會教
yt_token.json: (missing)
(missing) 是正常的,下一段教怎麼填。
---
🔑 第一次設定:OAuth credential
YouTube Data API 必須走 OAuth,不能用簡單的 API key。這是 Google 規定,不是我設計——讀寫使用者的 YouTube 內容就一定要 OAuth。
整個流程約 3 分鐘,一輩子做一次。
Step 1:在 Google Cloud Console 開 project
yc-plugin),Organization 留空Step 2:開 YouTube Data API v3
這會給你的 project 開放 YouTube API 的呼叫額度(免費,每天 10,000 quota units,夠你上百支影片)。
Step 3:設 OAuth consent screen
- App name:填什麼都可以(例如
yc-plugin)- User support email:你的 Gmail
- Developer contact:你的 Gmail
Error 403: access_denied)Step 4:建 OAuth client ID
下載下來的檔名通常是 client_secret_xxxxxxxx.apps.googleusercontent.com.json。
Step 5:餵給 plugin
打開 Claude Code,下:
/yc-plugin:youtube-setup install /path/to/client_secret.json
例如:
/yc-plugin:youtube-setup install ~/Downloads/client_secret_xxxx.apps.googleusercontent.com.json
Plugin 會:
~/.config/yc-plugin/client_secret.jsonchmod 600(只有你自己能讀)~/.config/yc-plugin/yt_token.json驗證:
/yc-plugin:youtube-setup --show
預期看到:
client_secret.json: ✓ installed
yt_token.json: ✓ active (expires in N days)
為什麼這麼麻煩?能不能用我的 credential?
不行。OAuth 是「使用者授權給應用程式存取我的資料」的協定,每個人都得有自己的「使用者授權」。我能分享給你的是 client_secret.json(應用程式身份),但你還是得用你的 Google 帳號授權一次。下一段「分享給朋友」會講這個。
---
✏️ 我實際下的指令
設定完之後,每次上傳就一條指令:
/yc-plugin:youtube-upload ~/videos/episode-01.mp4 "EP1 開箱"
第一個參數是影片路徑,引號內是預設標題(可省,省了用檔名)。
下完之後 Claude Code 會問你:
上傳前確認(不填就用預設):
標題: episode-01
描述: (可貼長文,最多 5000 字)
Tags: (逗號分隔)
隱私: unlisted (其他選項: public / private)
封面圖: (路徑,jpg/png ≤2MB;按 enter 跳過)
排程發布: (例如 "2026-05-10 20:00";按 enter 立即發布)
播放清單: (名稱會自動建立,或 playlist ID;按 enter 跳過)
字幕檔: 自動偵測同名 .srt/.vtt(找到: episode-01.srt)
兒童內容: 否
自動偵測規則:
- 同目錄下
<影片>.srt、<影片>.vtt自動列出 cover.jpg、thumbnail.jpg、<影片>.jpg自動建議- 描述若你說「AI 寫」,從字幕內容草擬一段給你確認
{
"title": "EP1 開箱",
"description": "本集介紹...",
"tags": ["開箱", "EP1"],
"privacyStatus": "private",
"publishAt": null,
"categoryId": "22",
"playlist": "Episodes 2026"
}
問你「正確嗎?我送出?」你說「送」之後才真的上傳。
dry-run 是什麼意思?
「乾跑一次」——把要送出的 metadata 印給你看,不真的呼叫 API。
為什麼這樣設計:YouTube API 上傳的影片沒辦法用 API 完整刪除(你只能設成 private)。所以送出前讓你看一眼最後 metadata 比較安全。
上傳實況
確認之後 Plugin 會:
upload: 12.5 MB / 24.2 MB (51%)
upload: 24.2 MB / 24.2 MB (100%)
[OK] uploaded
processing: HD encoding...
processing: thumbnails...
DONE → https://youtu.be/qaarUAvCirU
實際我上傳一支 24MB 的 9 分鐘影片約 35 秒——大部分時間都在 YouTube 端 transcoding。Plugin 用 resumable upload,網路斷了會自動續傳。
---
💥 踩到的坑
坑 1:第一次授權瀏覽器跳的「Google 沒驗證這個 App」警告
第一次授權時你會看到這個畫面:
⚠️ Google hasn't verified this app
The app is requesting access to sensitive info in your Google Account.
Until the developer (xxx@gmail.com) verifies this app with Google, you shouldn't use it.
這是預期行為。因為這個 OAuth client 是你自己建的、沒送 Google verification(要送 verification 是給「給很多陌生人用」的 app 走的流程)。
解法:點「Advanced」→「Go to yc-plugin (unsafe)」。只要你信任自己建的 OAuth client,就是安全的——這個警告是給「別人寄連結叫你授權」的釣魚情境設的。
坑 2:thumbnail 上傳 403
[WARN] thumbnail upload failed: 403 channelNotEligible
原因:YouTube 規定頻道必須先驗證才能用 API 上傳自訂縮圖(要驗證手機)。
解法:到 youtube.com/verify 用手機驗證頻道,之後就能上自訂縮圖。
驗證之前可以先不傳縮圖——YouTube 會用影片自動截圖當預設縮圖。
坑 3:影片上傳完 YouTube 顯示「處理中」很久
不是 bug。YouTube 的 transcoding 會花時間(HD 約幾分鐘、4K 可能 30 分鐘以上)。Plugin 顯示 DONE 之後處理由 YouTube 接手,跟 Plugin 沒關係。
如果你需要確定處理完才公開,先傳成 private 或 unlisted,等處理完再到 Studio 改 public。或用 --publish-at "2026-05-10 20:00" 排程發布——上傳時是 private,到時間自動切 public。
---
🎁 把 Plugin 分享給朋友
朋友也要用 yc-plugin?三步驟:
Step 1:朋友裝 plugin
請朋友打開 Claude Code 下:
/plugin marketplace add yanchen184/yc-plugin
/plugin install yc-plugin@yc-plugin
這跟你裝法一模一樣。
Step 2:給朋友 credentials zip
你做一次:
cd ~/Downloads
zip -e yc-plugin-creds.zip ~/.config/yc-plugin/client_secret.json
# 系統會問密碼,輸兩次
把 yc-plugin-creds.zip 傳給朋友(LINE / Email / Drive 都可),密碼用另一條通道告訴他(口頭、Signal、簡訊等)。
Step 3:朋友 import
朋友拿到 zip 後跑:
/yc-plugin:youtube-setup import ~/Downloads/yc-plugin-creds.zip
Plugin 會:
client_secret.json 搬到他的 ~/.config/yc-plugin/完成。他用他的帳號授權,影片會傳到他的頻道——你們共用 OAuth client,但 YouTube 內容完全分開。
⚠️ 重要:你朋友的 Google 帳號必須先在你的 OAuth consent screen 加進 Test users(Step 3:設 OAuth consent screen)。否則授權時會被擋成 Error 403: access_denied。
這個分享方式安全嗎?
ZIP 加密用 AES-256,夠擋掉「不小心被路人看到」。如果你的威脅模型是「全國級對手」要走 GPG / age;對普通工程師之間共用 credentials,加密 zip + 密碼分通道已經是合理門檻。
---
❓ 常見問題
yc-plugin 是免費的嗎?
是。Plugin 本身 MIT 授權。YouTube Data API v3 也免費(每天 10,000 quota,上傳一支影片約消耗 1,600 quota,夠你每天傳 6 支)。只有你超過免費額度才需要付費。
跟 youtube-upload (Tokland 版) 比哪個好?
yc-plugin 走 Google 官方 SDK、跟 Claude Code 整合、有自動偵測字幕 / 縮圖;Tokland 版是 standalone CLI 但 2020 之後沒大更新。如果你已經在用 Claude Code 工作流,yc-plugin 會更順。
要付 OpenAI / Anthropic 的錢才能用嗎?
Plugin 本身不需要。Plugin 是 Python 腳本 + Claude Code 的 commands,本身呼叫 YouTube API。只有你跟 Claude Code 對話的部分才用 Anthropic API(你已經在用 Claude Code 就是這個帳號)。
我的 credentials 安全嗎?
client_secret.json 跟 yt_token.json 都存在 ~/.config/yc-plugin/,chmod 600(只有你自己能讀)。Plugin 不會把這兩個檔案傳到任何地方——所有上傳直接從你的本機呼叫 YouTube API。原始碼都開放可審。
大檔影片(>1GB)會卡嗎?
不會。Plugin 用 Google SDK 內建的 resumable upload + exponential backoff——斷網重連會自動續傳。我自己傳過 4GB 的 1080p 沒問題。
為什麼一定要 Desktop app 不能用 Web app?
Desktop app 走 loopback redirect(本機 http://localhost:port)授權;Web app 走外網 redirect URI——你沒有公開網域不能驗證。Plugin 是本機跑的所以一定要 Desktop。
---
🔗 延伸資源
- yc-plugin GitHub repo(含完整 README + 安裝指引)
- YouTube Data API v3 官方文件
- Claude Code Plugin 系統官方文件
- 本站相關文章:自製 Plugin 踩過的四個坑
- 本站相關文章:如何馴服 Claude Code
我輩修行之人,以聖的標準要求自己,以凡的眼光理解別人。