Athlon1600 / youtube-downloader

:tv: PHP based alternative to youtube-dl and yt-dlp. Active and frequently updated! :star:
https://unblockvideos.com/
MIT License
800 stars 316 forks source link

Not able to get URLs from Age Restricted videos, even though setting cookies #155

Open fightveryexplosion opened 2 years ago

fightveryexplosion commented 2 years ago

Hello. First of all, thank you so much for a very helpful library! It works flawlessly and I am thrilled to have found such a stabile version of youtube-dl that is actually made in PHP instead of Python.

I'm having trouble with getting the URLs for age restricted videos. I have downloaded my Youtube cookies into a .txt file, and tried setting it like below;

$youtube = new YouTubeDownloader();
$youtube->getBrowser()->setCookieFile('{actual path to directory}/youtube_cookies.txt');

try {
    $downloadOptions = $youtube->getDownloadLinks("https://www.youtube.com/watch?v=".$videoID);
    $urls = array();
      if ($downloadOptions->getAllFormats()) {
          foreach ($downloadOptions->getAllFormats() as $format) {

              $url = $format->url;
             echo $url;
          }

      } else {
          http_response_code(404);
              exit();
      }

} catch (YouTubeException $e) {
  http_response_code(404);
  exit();
}

What happens is that no exception is thrown, and instead getAllFormats() is empty. The details of the video, (the title and description, etc) are returned without problem.

I have also tried the same cookies file out with youtube-dl and I was able to get the URLs without problem, but while using Youtube-Downloader it just doesn't seem to work.

I have tried a couple of age restricted videos and none work. These are a few of the ones I have tried;

https://www.youtube.com/watch?v=x8VYWazR5mE https://www.youtube.com/watch?v=eDY_Jdbhjyk https://www.youtube.com/watch?v=NIABFcVB3Is

Any advice or help with solving this would be greatly appreciated! If there is any additional information I can provide, let me know! Thank you.

felipe-silveira-dev commented 1 year ago

Did you fix it ?