Allow scoping the proxy to lookups only

YouTube's bot checks started once traffic went through a proxy exit IP,
while direct downloads had worked. YTDLP_PROXY_SCOPE=search keeps the
proxy on search and metadata — where it is needed to get past filtered
results — and lets the audio stream go out directly. Default stays "all",
so nothing changes unless it is set.

Searches also now run against a throwaway copy of the cookie file: they
run in parallel and yt-dlp rewrites that file on exit, so two of them
could clobber the jar the downloads depend on.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Leonid Pershin
2026-09-09 00:37:57 +03:00
co-authored by Claude Opus 5
parent 2ee907626e
commit 24dfcf9232
4 changed files with 75 additions and 14 deletions
+5
View File
@@ -43,6 +43,11 @@ const schema = z.object({
YTDLP_PATH: z.string().default("yt-dlp"),
YTDLP_COOKIES: z.string().optional(),
/**
* Where the proxy applies: "all" for every request, "search" to keep the audio
* stream direct — useful when a proxy exit IP triggers YouTube's bot checks.
*/
YTDLP_PROXY_SCOPE: z.enum(["all", "search"]).default("all"),
/** Proxy for every yt-dlp request: http://, https://, socks5:// or socks5h://. */
YTDLP_PROXY: z
.string()