Document YouTube cookie auth and warn when the file is unusable

Cookies were already wired up but only mentioned in passing, and the
non-obvious parts were undocumented: yt-dlp has no username/password
support for YouTube, it rewrites the cookie file to persist rotated
cookies (so a read-only file expires early), and the export has to
happen in a private window that is logged out before closing.

Startup now reports whether the cookie file is usable, missing, or
read-only, and YTDLP_EXTRACTOR_ARGS is passed through for the cases
where YouTube blocks a server IP outright.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Leonid Pershin
2026-09-08 23:26:48 +03:00
co-authored by Claude Opus 5
parent 1ac99b4a10
commit 2b999bf2a0
6 changed files with 443 additions and 367 deletions
+13 -1
View File
@@ -3,7 +3,7 @@ import { startBot } from "./bot/index.js";
import { config } from "./config.js";
import { MusicManager } from "./core/manager.js";
import { logger } from "./logger.js";
import { checkYtDlp } from "./sources/index.js";
import { checkCookies, checkYtDlp } from "./sources/index.js";
async function main(): Promise<void> {
const ytdlpVersion = await checkYtDlp();
@@ -16,6 +16,18 @@ async function main(): Promise<void> {
);
}
const cookies = await checkCookies();
if (cookies === "ok") {
logger.info({ path: config.YTDLP_COOKIES }, "using YouTube cookies");
} else if (cookies === "read-only") {
logger.warn(
{ path: config.YTDLP_COOKIES },
"cookie file is not writable — yt-dlp cannot persist rotated cookies and the session will expire early",
);
} else if (cookies === "missing") {
logger.warn({ path: config.YTDLP_COOKIES }, "cookie file from YTDLP_COOKIES does not exist");
}
const manager = new MusicManager();
const bot = await startBot(manager);
const app = await startApiServer({ manager, context: bot.context });