get('http://www.youtube.com/v/' . $id); $url = $c->last_url(); $t = str_replace('&t=', '', strrchr($url, "&t=")); return 'http://www.youtube.com/get_video?video_id=' . $id . '&t=' . $t; } class CurlSingle { function setup() { $cookieJar = 'cookies.txt'; curl_setopt($this->curl,CURLOPT_COOKIEJAR, $cookieJar); curl_setopt($this->curl,CURLOPT_COOKIEFILE, $cookieJar); curl_setopt($this->curl,CURLOPT_AUTOREFERER, true); curl_setopt($this->curl,CURLOPT_FOLLOWLOCATION, true); curl_setopt($this->curl,CURLOPT_RETURNTRANSFER, true); curl_setopt($this->curl,CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.8.1.11) Gecko/20071127 Firefox/2.0.0.11'); } function get($url) { $this->curl = curl_init($url); $this->setup(); return $this->request(); } function getAll($reg,$str) { preg_match_all($reg,$str,$matches); return $matches[1]; } function post($url, $fields, $referer='') { $timeout = 0; $this->curl = curl_init($url); $this->setup(); curl_setopt($this->curl, CURLOPT_URL, $url); curl_setopt($this->curl, CURLOPT_POST, 1); curl_setopt($this->curl, CURLOPT_REFERER, $referer); curl_setopt($this->curl, CURLOPT_POSTFIELDS, $fields); curl_setopt($this->curl, CURLOPT_CONNECTTIMEOUT, $timeout); curl_setopt($this->curl, CURLOPT_HTTPHEADER, array('Expect:')); return $this->request(); } function last_url() { return curl_getinfo($this->curl, CURLINFO_EFFECTIVE_URL); } function request() { return curl_exec($this->curl); } } ?>