Use the Ego Lite session to senda local videoto YouTube Studio. Success means obtaining thevideo link / video ID, and reading the processing status (Uploading, Upload complete, Processing, Checks complete, Saved, or Published).
Publish a local video file to YouTube Studio. Success is a video URL or ID plus a processing status. This skill does not download video and does not call yt-dlp.
Install Ego first
Install Ego Litefirst, and make sure ego-browser is in PATH. If missing, soft-fail / tell the user to install it,do notforce-invoke the browser.
Install Ego Lite and put ego-browser on PATH. If either is missing, soft-fail and tell the user. Do not hard-require the browser.
It works best when YouTube is already logged in within Ego. Tell the user this before every publish.
Being logged in to YouTube inside Ego gives the best results. Say that to the user before every publish.
Before every publish: login gate (mandatory)
Agent before uploadingyou must run:
node scripts/check-login.mjs
# 需要把窗口留给人登录时:
node scripts/check-login.mjs --keep
| Exit code | Meaning | What the agent does |
|---|---|---|
0 |
Logged in | Tell the user login_tip , and continue publishing |
2 |
Not logged in / no ego-browser | Show how_to_login / how_to_login_zh,Stop. Ask a person to log in to YouTube in Ego, then run check-login again |
1 |
Other error | Report the JSON error, do not pretend it was published |
See references/login.md. Do not create a separate cookie-healthcheck skill.
By default, only finish({ keep: [] })。--keep keeps the login page open and handOff()。
Input (generic, no local product paths)
The caller provides the local file and copy. See references/inputs.md. This skilldoes notbind to any product line, podcast, or business directory, and alsodoes notdownload videos.
At minimum you need: the local video path,title。description may be empty.tags、thumbnail optional.visibility default private(unlisted / public must be explicitly requested by the caller). Made for kids defaults to No。
CLI
ego-browser nodejs does not inherit shell environment variables, nor forward shell argv.publish.sh First write the JSON to /tmp/youtube-video-publish.json, then hand it to ego.
# 仓库根目录
node skills/youtube-video/scripts/check-login.mjs
node skills/youtube-video/scripts/check-login.mjs --keep
bash skills/youtube-video/scripts/publish.sh /absolute/path/to/video.mp4 "Title" "Description"
bash skills/youtube-video/scripts/publish.sh \
--video /absolute/path/to/video.mp4 \
--title "Title" \
--description "Description" \
--tags "one,two" \
--visibility private \
--thumbnail /absolute/path/to/thumbnail.jpg \
--made-for-kids no \
--space-id 4 \
--keep
In the installed skill directory, use a relative path:node scripts/check-login.mjs、bash scripts/publish.sh …。
| Exit code | Meaning |
|---|---|
0 |
Success. stdout contains {"ok":true,"videoId":"…","videoUrl":"https://youtu.be/…","status":"Processing",…} |
1 |
Parameter or flow error |
2 |
Login required, or there is no ego-browser |
Do not start another upload for troubleshooting. After a login handOff or interruption, use --space-id to return to the original space.
What the publishing script does
- Open
https://studio.youtube.com/。 - Determine login from the body. If it redirects to
accounts.google.com//signin, or the body is Google login / choose an account, then exit 2. "YouTube Studio" in the document title does not count as logged in. - Click Create (
#create-icon), then click "Upload videos", until#select-files-button。 - first
waitForFileChooser, then click select file and hand the caller's local video to the file picker. - Wait until progress or the
youtu.belink appears. - Write the title and description (may be empty). The title is in the shadow DOM's
#textbox; after writing, read it back; it must match the passed-in title. - If there is a thumbnail, then use the file picker to click
#file-loader(or Upload thumbnail). - If there are tags, first click Show more, then write
#tags-container。 - Audience settings default to clicking No, it's not made for kids(
VIDEO_MADE_FOR_KIDS_NOT_MFK). Only click Yes when the caller explicitly requests it. - Click Next three times until the visibility radio buttons appear. By default click Private。
publicOnly select it when the caller passes it in; the button label is then Publish; for private / unlisted it is Save. - Click
#done-button。 - Success: extract the 11-character video ID from the page link and read the processing status. Do not wait for HD processing to finish.
By default, both success and failure finish({ keep: [] }). Only --keep keeps the page open.
Pitfalls
The full checklist is in references/pitfalls.md. Run login-check before publishing; you must stop on exit 2. Do not mistake not being logged in for having published.
Manual fallback
publish.js After an error, the spaceId in the JSON can return to the original space. Do not open another space just to troubleshoot.
ego-browser nodejs <<'EOF'
const task = await taskSpace(4);
const page = task.page("p1");
console.log({ url: await page.url() });
console.log(await page.snapshot());
EOF
Replace 4 with the actual spaceId. When done, run finish({ keep: [] })。
Test
npm test