Fork Copy $name){ $instructions[] = array($functions[$name], $matches[3][$index]); } return $instructions; } } } return false; } // YouTube is capitalized twice because that's how youtube itself does it: // https://developers.google.com/youtube/v3/code_samples/php class YouTubeDownloader { private $storage_dir; private $cookie_dir; private $itag_info = array( 18 => "360P", 22 => "720P", 37 => "1080P", 38 => "3072P", // questionable MP4s 59 => "MP4480P", 78 => "MP4480P", 43 => "WebM360P", 17 => "3GP144P" ); function __construct(){ $this->storage_dir = sys_get_temp_dir(); $this->cookie_dir = sys_get_temp_dir(); } function setStorageDir($dir){ $this->storage_dir = $dir; } // what identifies each request? user agent, cookies... public function curl($url){ $ch = curl_init($url); curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 6.3; WOW64; rv:49.0) Gecko/20100101 Firefox/49.0'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_HEADER, 0); //curl_setopt($ch, CURLOPT_COOKIEJAR, $tmpfname); //curl_setopt($ch, CURLOPT_COOKIEFILE, $tmpfname); //curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); $result = curl_exec($ch); curl_close($ch); return $result; } public static function head($url){ $ch = curl_init($url); curl_setopt($ch, CURLOPT_HEADER, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0); curl_setopt($ch, CURLOPT_NOBODY, 1); $result = curl_exec($ch); curl_close($ch); return http_parse_headers($result); } // html code of watch?v=aaa private function getInstructions($html){ // // check what player version that video is using if(preg_match('@