All pastes #1036934 Raw Edit

Someone

public php v1 · immutable
#1036934 ·published 2008-06-02 15:31 UTC
rendered paste body
<?phpecho get_youtube_flv("http://www.youtube.com/watch?v=-qScD5orNAI&feature=bz302");/*********************************************************************************/function get_youtube_flv($input, $type = 'url'){	$c = new CurlSingle;	if($type == 'url')	{		$input = str_replace('?v=', '', strrchr($input, '?v='));		$id = str_replace(strrchr($input, '&'), '', $input);	} 	else if ($type == 'id')		$id = $input;			$c->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);    }}?>