Support a proxy for networks where YouTube is unreachable

YTDLP_PROXY routes every yt-dlp call — search, metadata and the audio
stream, for YouTube and SoundCloud alike — through an http(s) or SOCKS
proxy such as a local Psiphon. Startup logs which proxy is in use with
any credentials stripped.

ffmpeg has no SOCKS support, so with a proxy configured playback always
goes through the yt-dlp pipe instead of a resolved CDN URL: nothing
escapes past the proxy, at the cost of slower seeking. Direct links keep
using ffmpeg, which gets the proxy only when it speaks http(s).

Verified against a dead proxy: requests fail through it rather than
quietly going direct.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Leonid Pershin
2026-09-09 00:24:09 +03:00
co-authored by Claude Opus 5
parent 6d65134f8e
commit 71b9b7fe17
7 changed files with 104 additions and 24 deletions
+8
View File
@@ -43,6 +43,14 @@ const schema = z.object({
YTDLP_PATH: z.string().default("yt-dlp"),
YTDLP_COOKIES: z.string().optional(),
/** Proxy for every yt-dlp request: http://, https://, socks5:// or socks5h://. */
YTDLP_PROXY: z
.string()
.optional()
.refine(
(value) => !value || /^(https?|socks[45]h?):\/\//i.test(value),
"должен начинаться с http://, https://, socks5:// или socks5h://",
),
/** Extra `--extractor-args` values, separated by ";" — e.g. youtube:player_client=default,web_safari */
YTDLP_EXTRACTOR_ARGS: z.string().optional(),
LOCAL_MEDIA_DIR: z.string().optional(),