Athlon1600 / youtube-downloader

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

not getting private videos even with cookies file #149

Closed shorts7wound closed 3 years ago

shorts7wound commented 3 years ago

i keep getting error video not found exception even when adding cookies files am i missing smth?

Athlon1600 commented 3 years ago

I would need to see your exact code and video you are trying to download

shorts7wound commented 3 years ago

thanks for fast response , for now i am just trying to make it work first

require __DIR__ . '/vendor/autoload.php';

use YouTube\YouTubeDownloader;
use YouTube\Exception\YouTubeException;

$youtube = new YouTubeDownloader();

try {
    $downloadOptions = $youtube->getDownloadLinks("https://www.youtube.com/watch?v=vnODB9CZWZw");
    $youtube->getBrowser()->consentCookies();

    $youtube->getBrowser()->setCookieFile('cookies.txt');
    $youtube->getBrowser()->setUserAgent('Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.81 Safari/537.36');

    var_dump($youtube);
    if ($downloadOptions->getAllFormats()) {

        var_dump( $downloadOptions);

    } else {
        echo 'No links found';
    }

} catch (YouTubeException $e) {
    echo 'Something went wrong: ' . var_dump($e);
}

i get the exeption that the video doesnot exist but it exists in my channel and is private

Athlon1600 commented 3 years ago

i get the exeption that the video doesnot exist but it exists in my channel and is private

oh, well that complicates things... My guess is that the cookies you are passing down to your Browser instance aren't in a valid format or are missing.

If you are on Firefox, you should install this extension: https://addons.mozilla.org/en-US/firefox/addon/export-cookies-txt/

go to youtube.com, login. Export the cookies via that extension to cookies.txt, and then use that file when downloading private videos.

I just tested this, and this seems to work just fine. Let me know.

shorts7wound commented 3 years ago

yes i even deleted all cache and cookies logged in and exported also disabled 2 factor aut and enabled less secure apps however when trying with youtube-dl its working using the code ~# youtube-dl --cookies /www/wwwroot/youtubedlphp/cookies.txt https://www.youtube.com/watch?v=jNhBrC_c5Qg [youtube] jNhBrC_c5Qg: Downloading webpage [youtube] jNhBrC_c5Qg: Downloading MPD manifest [dashsegments] Total fragments: 55 [download] Destination: VID 20150619 223117-jNhBrC_c5Qg.f133.mp4 [download] Got server HTTP error: HTTP Error 404: Not Found. Retrying fragment 1 (attempt 1 of 10)... [download] 100% of 5.36MiB in 00:31 [download] Destination: VID 20150619 223117-jNhBrC_c5Qg.f140.m4a [download] 100% of 4.36MiB in 00:56 [ffmpeg] Merging formats into "VID 20150619 223117-jNhBrC_c5Qg.mp4" Deleting original file VID 20150619 223117-jNhBrC_c5Qg.f133.mp4 (pass -k to keep) Deleting original file VID 20150619 223117-jNhBrC_c5Qg.f140.m4a (pass -k to keep)

Athlon1600 commented 3 years ago

tested it again, yes downloading private videos is a bit different, and I already know what I would have to change to make this work. Adding to my to-do list...