Skip to main content

yt-dlp-proxyhat

Download videos with yt-dlp through ProxyHat residential proxies — unblock region-locked videos by fetching them through a residential IP in the right country, with a sticky IP per download plus rotation and socks5.

CI Compatible with yt-dlp latest PyPI License: MIT

Why

Lots of videos are geo-restricted — available in one country and blocked everywhere else. yt-dlp can route through a proxy, but only if you have a residential exit IP in the right place. This package plugs ProxyHat's residential IPs (50M+ across 148+ countries) into yt-dlp's first-class proxy option: pick a country and the whole download — manifest and every fragment — comes from a real residential IP there, so the site serves the video instead of a geo-block. No fork, no boilerplate.

Install

pip install yt-dlp-proxyhat

yt-dlp is a peer dependency — bring your own version. proxyhat_proxy_url() and proxyhat_ydl_opts() work on their own; ProxyHatYoutubeDL needs yt-dlp installed:

pip install yt-dlp-proxyhat yt-dlp

Quick start

CLI

yt-dlp takes one proxy per run via --proxy URL. Generate the URL and hand it over:

yt-dlp --proxy "$(PROXYHAT_API_KEY=ph_xxx python -m yt_dlp_proxyhat --country us)" \
  "https://www.youtube.com/watch?v=..."

(Or wire the URL however you like — see examples/cli.py.)

Python API

from yt_dlp_proxyhat import ProxyHatYoutubeDL

# An API key auto-selects an active residential sub-user:
with ProxyHatYoutubeDL({"format": "best"}, country="us") as ydl:  # sticky US IP for the whole run
    ydl.download(["https://www.youtube.com/watch?v=..."])

Get an API key at proxyhat.com.

Already building your own YoutubeDL? Grab the opts dict or the raw URL:

import yt_dlp
from yt_dlp_proxyhat import proxyhat_ydl_opts, proxyhat_proxy_url

# Merge the proxy into your own options:
opts = proxyhat_ydl_opts(country="gb", base={"format": "bestvideo+bestaudio", "outtmpl": "%(title)s.%(ext)s"})
with yt_dlp.YoutubeDL(opts) as ydl:
    ydl.download(["https://www.youtube.com/watch?v=..."])

# ...or just the URL string:
url = proxyhat_proxy_url(country="jp", sticky="1h")
# -> "http://<user>-country-jp-sid-<id>-ttl-1h:<pass>@gate.proxyhat.com:8080"

Credentials

Pass them explicitly or via environment variables — options win over env:

Option Env var Notes
api_key PROXYHAT_API_KEY Auto-selects an active sub-user with remaining traffic
sub_user PROXYHAT_SUBUSER Pick a specific sub-user by uuid or name (with an API key)
username PROXYHAT_USERNAME Explicit gateway proxy_username (skips the API)
password PROXYHAT_PASSWORD Explicit gateway proxy_password

Targeting

Every option is accepted by proxyhat_proxy_url, proxyhat_ydl_opts and ProxyHatYoutubeDL:

ProxyHatYoutubeDL(
    {"format": "best"},  # your normal yt-dlp params dict (first positional arg)
    protocol="http",     # or "socks5"
    country="us",        # ISO code or "any" (default) — set this to unblock geo-locked video
    region="california",
    city="new_york",
    filter="high",       # AI IP-quality tier
    sticky="30m",        # session lifetime (default); sticky=False rotates per run
    auto_init=False,     # any extra kwarg is forwarded to yt_dlp.YoutubeDL
)

Geo-unblocking

This is the main use. Set country to a region the video is available in, and yt-dlp fetches it through a residential IP there:

# A video only playable in Japan:
with ProxyHatYoutubeDL(country="jp") as ydl:
    ydl.download(["https://www.youtube.com/watch?v=..."])

yt-dlp also has its own geo_bypass (spoofs X-Forwarded-For), but many sites ignore that header — a real residential exit IP in the target country is what actually works, and it's what a proxy gives you.

Sticky IP per run (default) vs rotation

yt-dlp uses one proxy for the whole run, so stickiness here is about that run, and "rotation" means a fresh IP on the next run/connection — never mid-download. A download pulls a manifest and then many fragments; they must all come from the same country, so this package is sticky by default: one residential IP is pinned for the run (sticky="30m").

Want a fresh IP on the next run instead (e.g. a loop over many URLs, each from a new IP)? Turn stickiness off — mint a new proxy per run:

from yt_dlp_proxyhat import ProxyHatYoutubeDL

for url in urls:
    with ProxyHatYoutubeDL(country="us", sticky=False) as ydl:  # fresh residential IP each run
        ydl.download([url])

Set a custom lifetime with sticky="2h".

How it works

proxyhat_proxy_url(...) resolves your gateway credentials (via the official proxyhat SDK — an API key auto-picks an active sub-user, or pass username/password), then builds the proxy URL: the host is the ProxyHat gateway (gate.proxyhat.com:8080, or :1080 for SOCKS5) and the username carries ProxyHat's targeting grammar (<user>-country-us-sid-<id>-ttl-30m). proxyhat_ydl_opts(...) drops that URL into yt-dlp's proxy params key (merging your base options); ProxyHatYoutubeDL is a thin yt_dlp.YoutubeDL subclass that does it for you (yt-dlp is imported lazily, so importing this package is cheap and needs no yt-dlp install). A sticky username (with a session id) pins one residential IP for the download; a rotating one (no session id) makes the gateway hand out a fresh IP on the next connection.

License

MIT © ProxyHat

Metadata

Release files for yt-dlp-proxyhat 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for yt-dlp-proxyhat 0.1.1
File Size Uploaded
yt_dlp_proxyhat-0.1.1.tar.gz 12.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for yt-dlp-proxyhat 0.1.1
File Interpreter ABI Platform
yt_dlp_proxyhat-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 22.6 kB

Release files / yt_dlp_proxyhat-0.1.1.tar.gz

Download URL yt_dlp_proxyhat-0.1.1.tar.gz
Size 12.3 kB
Tags Source
SHA-256 checksum
How to use checksums
5a7c9ee222d5a91a1dd3db15615e33a70883e5d763d730afa6dc2bd14970c68f
BLAKE2b-256 checksum
How to use checksums
5a7187d0ab9b54f8265209743720cc4a011fdc6d8738fcc4de225ea84c681ab0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 14, 2026.

Transparency log

Release files / yt_dlp_proxyhat-0.1.1-py3-none-any.whl

Download URL yt_dlp_proxyhat-0.1.1-py3-none-any.whl
Size 10.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
008c9d45db424fddbd3fbf37002ece6f7c18cf84290f25a05efde68e4146af54
BLAKE2b-256 checksum
How to use checksums
7c4ccc25fd8aee938f1fa8884463c5c66977748843d1c39a47f80b646f9cd24f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 14, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page