streamingData->formats; $adaptiveFormats = $playabilityJson->streamingData->adaptiveFormats; //Checking playable or not $IsPlayable = $playabilityJson->playabilityStatus->status; //writing to log file if(strtolower($IsPlayable) != 'ok') { $log = date("c")." ".$info['player_response']."\n"; file_put_contents('./video.log', $log, FILE_APPEND); } $result = array(); if(!empty($info) && $info['status'] == 'ok' && strtolower($IsPlayable) == 'ok') { $i=0; foreach($adaptiveFormats as $stream) { $streamUrl = $stream->url; $type = explode(";", $stream->mimeType); $qualityLabel=''; if(!empty($stream->qualityLabel)) { $qualityLabel = $stream->qualityLabel; } $videoOptions[$i]['link'] = $streamUrl; $videoOptions[$i]['type'] = $type[0]; $videoOptions[$i]['quality'] = $qualityLabel; $i++; } $j=0; foreach($formats as $stream) { $streamUrl = $stream->url; $type = explode(";", $stream->mimeType); $qualityLabel=''; if(!empty($stream->qualityLabel)) { $qualityLabel = $stream->qualityLabel; } $videoOptionsOrg[$j]['link'] = $streamUrl; $videoOptionsOrg[$j]['type'] = $type[0]; $videoOptionsOrg[$j]['quality'] = $qualityLabel; $j++; } $result['videos'] = array( 'info'=>$info, 'adapativeFormats'=>$videoOptions, 'formats'=>$videoOptionsOrg ); return $result; } else { return; } } }
Download YouTube Video
getYouTubeCode($videoLink); if($vid) { $result = $yt->processVideo($vid); if($result) { //print_r($result); $info = $result['videos']['info']; $formats = $result['videos']['formats']; $adapativeFormats = $result['videos']['adapativeFormats']; $videoInfo = json_decode($info['player_response']); $title = $videoInfo->videoDetails->title; $thumbnail = $videoInfo->videoDetails->thumbnail->thumbnails{0}->url; } else { $error = "Something went wrong"; } } } else { $error = "Please enter a YouTube video URL"; } } ?>
With Video & Sound
Type Quality Download
Download
Videos video only/ Audios audio only
Type Quality Download
Download