> For the complete documentation index, see [llms.txt](https://doc.thordata.com/doc/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://doc.thordata.com/doc/proxies/high-bandwidth-proxies/youtube-downloader-yt_dlp-integration.md).

# YouTube Downloader (yt\_dlp) integration

Learn how to integrate yt-dlp with High Bandwidth Proxies for efficient YouTube video and audio scraping. Includes command-line examples and tips for using unique IPs per download.

### Example Integration: YouTube Downloader <a href="#example-integration-youtube-downloader" id="example-integration-youtube-downloader"></a>

Here's an example using `yt-dlp` with our High Bandwidth Proxies for video or audio data scraping:

#### Basic Usage <a href="#basic-usage" id="basic-usage"></a>

{% tabs %}
{% tab title="Command Line" %}

```sh
yt-dlp --proxy username:password@endpoint:9999 \
"https://www.youtube.com/watch?v=WNCl-69POro"
```

{% endtab %}

{% tab title="Python" %}

```python
import yt_dlp

username = 'YOUR_USERNAME'
password = 'YOUR_PASSWORD'

proxy = f'http://{username}:{password}@endpoint:9999'

ydl_opts = {
    'proxy': proxy,
}

with yt_dlp.YoutubeDL(ydl_opts) as ydl:
    ydl.download(['https://www.youtube.com/watch?v=WNCl-69POro'])
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
For optimal performance, make sure each video is downloaded using a separate IP address. Refer to the section below for guidance.
{% endhint %}

#### Multiple URLs with Different IPs <a href="#multiple-urls-with-different-ips" id="multiple-urls-with-different-ips"></a>

While using High Bandwidth Proxies, every video is downloaded with a separate IP address to ensure the optimal performance. This is achieved by generating a unique session ID for each request, which effectively assigns a new IP address for each download.

{% tabs %}
{% tab title="Command Line" %}

```sh
# First video with one IP
yt-dlp --proxy username-sessid-your_sessid-sesstime-your_sesstime:password@endpoint:9999 \
"https://www.youtube.com/watch?v=6stlCkUDG_s"

# Second video with different IP
yt-dlp --proxy username-sessid-your_sessid-sesstime-your_sesstime:password@endpoint:9999 \
"https://www.youtube.com/watch?v=gsnqXt7d1mU"
```

{% endtab %}

{% tab title="Python" %}

```python
import yt_dlp


def download_with_new_ip(url, username, password):
    sessid = "your-sessid"
    sesstime = "your-sesstime"
    proxy = f'http://{username}-sessid-{sessid}-sesstime-{sesstime}:{password}@your-endpoint:9999'

    ydl_opts = {
        'proxy': proxy
    }

    with yt_dlp.YoutubeDL(ydl_opts) as ydl:
        try:
            print(f"Downloading {url} with new IP ({username}-sesstime-10)...")
            ydl.download([url])
            print(f"Successfully downloaded {url}")
        except Exception as e:
            print(f"Error downloading {url}: {str(e)}")


def main():
    username = 'YOUR_USERNAME'
    password = 'YOUR_PASSWORD'

    videos = [
        'https://www.youtube.com/watch?v=_SdpvpvVrLY',
        'https://www.youtube.com/watch?v=2LEgs_H2gYg'
    ]

    for video in videos:
        download_with_new_ip(video, username, password)


if __name__ == "__main__":
    main()
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
The function includes basic error handling to ensure the process continues even if one download fails.
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://doc.thordata.com/doc/proxies/high-bandwidth-proxies/youtube-downloader-yt_dlp-integration.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
