youtube-downloader icon indicating copy to clipboard operation
youtube-downloader copied to clipboard

How to specify the IP address to use

Open ndsda opened this issue 3 years ago • 2 comments

Is there an easy way to specifiy the IP address to use for requests?

My server has 8 IPs and it would be useful to be able to use all of them to avoid the 'Too many requests' problem.

If this functionality doesn't exist, perhaps it could be considered for inclusion in future versions (if it isn't already been!)

ndsda avatar Jul 22 '21 13:07 ndsda

it's there already, and I use it myself all the time.

image

You might also want to use a separate cookies file and a different user-agent for each of those IPs, so as to appear entirely unique to YouTube

Athlon1600 avatar Jul 22 '21 21:07 Athlon1600

Is there a way for me to set the IP address with the CURLOPT_INTERFACE option?

Thanks for your advice about user-agents and cookie files.

ndsda avatar Jul 24 '21 23:07 ndsda

Is there a way for me to set the IP address with the CURLOPT_INTERFACE option?

Thanks for your advice about user-agents and cookie files.

For that, you could just modify Browser.php file:
https://github.com/Athlon1600/youtube-downloader/blob/master/src/Browser.php

and add something like:

    public function usingCustomIP($ip)
    {
        $this->options[CURLOPT_INTERFACE] = $ip;
        return $this;
    }

and then use it:

$youtube = new YouTubeDownloader();
$youtube->getBrowser()->usingCustomIP("YOUR_IP_GOES_HERE");

Athlon1600 avatar Oct 28 '23 00:10 Athlon1600