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

How to download videos using this utility? #184

Open ivansorlov opened 10 months ago

ivansorlov commented 10 months ago

Hi all! I'm sorry if my question sounds stupid. I'm new to programming. From the description I did not understand how to use this library. My task is to download videos to my hosting. Tell me, did I understand correctly that:

1) This code will be enough to download the video?

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

$youtube = new YouTubeDownloader();

try {
    $downloadOptions = $youtube->getDownloadLinks("https://www.youtube.com/watch?v=aqz-KE-bpKQ");

    if ($downloadOptions->getAllFormats()) {
        echo $downloadOptions->getFirstCombinedFormat()->url;
    } else {
        echo 'No links found';
    }

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

2) Is this code written in a PHP script?

3) Where is the video saved in this case?

NazmulHaque243 commented 10 months ago

check this https://github.com/NazmulHaque243/youtube-downloader