Let yt-dlp sign in with cookies when YouTube asks

When YouTube answers the server with "sign in to confirm you're not a
bot", yt-dlp needs a signed-in account's cookies. YTDLP_COOKIES points
at an exported cookies.txt, copied per download so the original is
never rewritten; YTDLP_COOKIES_FROM_BROWSER passes yt-dlp's
--cookies-from-browser for a browser on the server. Setup, and the
advice to use a separate account, is in docs/video-clips.md.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Zaldimmar 2026-09-28 03:03:48 -05:00
parent f1ac690abe
commit a393bde2da
2 changed files with 106 additions and 41 deletions

View file

@ -57,6 +57,27 @@ to an hour. Limits are constants at the top of `server/src/clips.js`.
A source can be several GB, so leave room on that disk.
**If YouTube says "Sign in to confirm you're not a bot"**, it's
refusing the VPS's address, and yt-dlp needs a signed-in account's
cookies. Use a separate Google account made for this, never a
personal one: whoever has the cookies is signed in as it. Then set
one of:
```ini
# A cookies.txt exported from a browser signed in to that account
# (a "Get cookies.txt" browser extension, Netscape format). Keep it
# readable only by the service: chmod 600, owned by its user.
Environment=YTDLP_COOKIES=/var/lib/ngu/youtube-cookies.txt
# Or: read them from a browser installed and signed in on the VPS
# itself, as yt-dlp's --cookies-from-browser takes it.
# Environment=YTDLP_COOKIES_FROM_BROWSER=firefox
```
The file is copied for each download, so yt-dlp never rewrites the
original. Cookies expire; when downloads start failing again, export
a fresh file.
4. **nginx**: the editor's video and clip downloads are big streams. Give
them their own block so nginx passes them straight through: