Server IP : 80.241.246.6 / Your IP : 216.73.216.188 Web Server : Apache/2.4.25 (Debian) System : Linux kharagauli 4.9.0-19-amd64 #1 SMP Debian 4.9.320-2 (2022-06-30) x86_64 User : www-data ( 33) PHP Version : 7.0.33-0+deb9u12 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority, MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/kharagauli1/moduls/video_gallery_2/site/youtube/ |
Upload File : |
<?php /* @author suxoza <suxoza@gmail.com> */ class Stream{ public $itags = [ '5' => ['320x240', 'flv', "normal"], '17'=> ['176x144', '3gp', "normal"], '18'=> ['640x360', 'mp4', "normal"], '22'=> ['1280x720', 'mp4', "normal"], '34'=> ['640x360', 'flv', "normal"], '35'=> ['854x480', 'flv', "normal"], '36'=> ['320x240', '3gp', "normal"], '37'=> ['1920x1080', 'mp4', "normal"], '38'=> ['4096x3072', 'superHD', "normal"], '43'=> ['640x360', 'webm', "normal"], '44'=> ['854x480', 'webm', "normal"], '45'=> ['1280x720', 'webm', "normal"], '46'=> ['1920x1080', 'webm', "normal"], '82'=> ['640x360-3D', 'mp4', "normal"], '84'=> ['1280x720-3D', 'mp4', "normal"], '100'=> ['640x360-3D', 'webm', "normal"], '102'=> ['1280x720-3D', 'webm', "normal"], '133'=> ['426x240', 'm4v', 'video'], '134'=> ['640x360', 'm4v', 'video'], '135'=> ['854x480', 'm4v', 'video'], '136'=> ['1280x720', 'm4v', 'video'], '137'=> ['1920x1080', 'm4v', 'video'], '138'=> ['4096x3072', 'm4v', 'video'], '139'=> ['48k', 'm4a', 'audio'], '140'=> ['128k', 'm4a', 'audio'], '141'=> ['256k', 'm4a', 'audio'], '160'=> ['256x144', 'm4v', 'video'], '171'=> ['128k', 'ogg', 'audio'], '172'=> ['192k', 'ogg', 'audio'], '247'=> ['unknown', 'unknown', 'unknown'], '248'=> ['unknown', 'unknown', 'unknown'] ]; public $url,$resolution,$extension,$title,$filename,$fsize,$mediatype; public function __construct($sm, $title = "ytvid", $js = NULL){ $this->url = $sm['url']; if(strpos($this->url,"signature=") === false) $this->url .= '&signature=' . $sm['sig']; if(strpos($this->url,"ratebypass=") === false) $this->url .= "&ratebypass=yes"; $this->itag = $sm['itag']; $this->resolution = $this->itags[$this->itag][0]; $this->extension = $this->itags[$this->itag][1]; $this->title = $title; $this->filename = $this->title . "." .$this->extension; $this->fsize = ''; $this->mediatype = $this->itags[$this->itag][2]; } function get_size() { $my_ch = curl_init(); curl_setopt($my_ch, CURLOPT_URL,$this->url); curl_setopt($my_ch, CURLOPT_HEADER, true); curl_setopt($my_ch, CURLOPT_NOBODY, true); curl_setopt($my_ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($my_ch, CURLOPT_TIMEOUT, 10); $r = curl_exec($my_ch); foreach(explode("\n", $r) as $header) { if(strpos($header, 'Content-Length:') === 0) { return $this->formatBytes(trim(substr($header,16))); } } return ''; } function formatBytes($bytes, $precision = 2) { $units = array('B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'); $bytes = max($bytes, 0); $pow = floor(($bytes ? log($bytes) : 0) / log(1024)); $pow = min($pow, count($units) - 1); $bytes /= pow(1024, $pow); return round($bytes, $precision) . '' . $units[$pow]; } function get_filesize(){ if(!$this->fsize){ $opts = array( 'http' => array( 'method' =>"GET", 'header' =>"content-length" ) ); try{ $context = stream_context_create($opts); $this->fsize = file_get_contents($this->url); }catch(Exception $ex){ $this->fsize = 0; } } return $this->fsize; } function download($file_target,$url = '') { $URL = (!$url)?$this->url:$url; $rh = fopen($URL,'rb'); $len = count($http_response_header); for($i = 0; $i < $len; $i++){ if(strpos($http_response_header[$i],"Content-Length:") !== false){ $length = (int)trim(explode(' ',$http_response_header[$i])[1]); break; } } $wh = fopen($file_target, 'wb'); if($rh === false || $wh === false)return; $chunksize = 16384; $bytesdone = 0; $t0 = time(); ob_start(); while(!feof($rh)){ $chunk = fread($rh, $chunksize); if(fwrite($wh, $chunk) === FALSE)return; $elapsed = time() - $t0; $bytesdone += strlen($chunk); $rate = ($bytesdone / 1024) / $elapsed; $eta = ($length - $bytesdone) / ($rate * 1024); $progress_stats = $bytesdone.' Bytes '. round($bytesdone * 100.0 / $length).'% received. Rate:'. round($rate).' kbps]. ETA: '. (int)$eta.' secs]'; echo "\r" .$progress_stats. "\r"; ob_flush(); flush(); } ob_end_flush(); fclose($rh); fclose($wh); return false; } } class vv{ public $video_url,$infoUrl,$vidid,$allinfo,$gdata,$xargs,$js,$title,$videoid,$length,$streams; public function __construct($ID){ $this->video_url = "http://www.youtube.com/watch?v="+$ID; $this->infoUrl = 'https://www.youtube.com/get_video_info?video_id='; $this->vidid = $ID; $this->infoUrl .= $this->vidid ."&asv=3&el=detailpage&hl=en_US"; $opener = ""; $keywords = ""; parse_str(file_get_contents($this->infoUrl),$this->allinfo); if(!count($this->allinfo) || $this->allinfo['status'] == 'fail')throw new Exception("video not found not found"); $this->gdata = NULL; $this->xargs = NULL; $this->js = NULL; $this->title = str_replace('/','-',$this->allinfo['title']); $this->videoid = $this->allinfo['video_id']; $this->length = (int)$this->allinfo['length_seconds']; $this->author = $this->allinfo['author']; $this->rating = (float)$this->allinfo['avg_rating']; $this->thumb = $this->allinfo['thumbnail_url']; $this->image = (isset($this->allinfo['iurlsd']))?$this->allinfo['iurlsd']:$this->allinfo['iurl']; $this->duration = ($this->length > 3600)?date('H:i:s',$this->length):date('i:s',$this->length); //$this->formats = [x.split("/") for x in $this->formats] $smap = $this->getstreammap('url_encoded_fmt_stream_map'); $this->streams = []; for($i = 0; $i < count($smap); $i++){ $this->streams[$i] = new Stream($smap[$i], $this->title, $this->js); unset($this->streams[$i]->itags); $this->streams[$i]->image = $this->image; $this->streams[$i]->rating = $this->rating; $this->streams[$i]->author = $this->author; $this->streams[$i]->thumb = $this->thumb; $this->streams[$i]->duration = $this->duration; $this->streams[$i]->videoid = $this->videoid; } // pre($this->allinfo); } function getall($key = ''){ if(!$key)return $this->streams; $masiv = []; for($i = 0; $i < count($this->streams); $i++){ if($this->streams[$i]->extension != $key)continue; $masiv[] = $this->streams[$i]; }return $masiv; } function getstreammap($key){ $streamMap = explode(',',$this->allinfo[$key]); $smaps = []; for($i = 0; $i < count($streamMap); $i++){ parse_str($streamMap[$i],$smap); $smaps[] = $smap; } return $smaps; } function getbest($type,$size = true,$extension = false){ $object = (!$extension)?$this->streams:$extension; $masiv = []; $bool = false; for($i = 0; $i < count($object); $i++){ if($object[$i]->extension != $type)continue; if(!$bool){$masiv = $object[$i];$bool = true;} if((int)$object[$i]->resolution > (int)$masiv->resolution) $masiv = $object[$i]; } if($size)$masiv->fsize = $masiv->get_size(); return $masiv; } } //$bb = new vv($ID); // return $bb; //}