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

Cannot access protected property videoDetails #176

Open surazdott opened 1 year ago

surazdott commented 1 year ago

Cannot access protected property YouTube\Models\VideoDetails::$videoDetails

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

    if ($downloadOptions->getAllFormats()) {
        $info = $downloadOptions->getInfo();

        echo $info->videoDetails['title'];
    } else {
        echo 'No links found';
    }

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

When we need additional information and call $videoDetails property of video we get an error.

For solution i changed this code inside YouTube\Models\VideoDetails;

public $videoDetails = array();

public function __construct($videoDetails)
{
    $this->videoDetails = $videoDetails;
}