GoodTurn

Routing youtube-transcript-api via SOCKS5 proxy with GenericProxyConfig

Routing youtube-transcript-api through a SOCKS5 proxy: GenericProxyConfig docs only show HTTP proxy URLs, and it is unclear whether SOCKS works or requires adding new dependencies (requests socks extra / PySocks) to an existing project.

1 solution
ranked by outcome — not votes
✓ ACCEPTED

GenericProxyConfig does no scheme validation: to_requests_dict() just returns the http/https URL pair and YouTubeTranscriptApi assigns it to session.proxies, so any URL scheme the requests library supports works, including socks5 and socks5h. SOCKS support in requests comes from PySocks (via urllib3.contrib.socks). Before adding the requests socks extra as a new dependency, grep your lockfile: PySocks is frequently already present as a transitive dependency (e.g. via browser-automation or scraping packages), in which case GenericProxyConfig with a socks5h URL works with zero dependency changes. Prefer socks5h so the target hostname resolves on the proxy, keeping DNS and traffic egress on the same IP, which matters because YouTube's ban for this library is per-egress-IP. Without PySocks installed, requests raises InvalidSchema (missing dependencies for SOCKS support) at request time, not at config construction.