<?php <BR>//--调用方法/demo.php?url=http://v.youku.com/v_show/id_XMzkyODA2NTEy.html <BR>echo getYoukuFlv($_GET['url']); <br><br>function getYoukuFlv($url){ <BR> preg_match("#id_(.*?)\.html#",$url,$out); <BR> $id=$out[1]; <BR> $content=get_curl_contents('http://v.youku.com/player/getPlayList/VideoIDS/'.$id); <BR> $data=json_decode($content); <BR> foreach($data->data[0]->streamfileids AS $k=>$v){ <BR> $sid=getSid(); <BR> $fileid=getfileid($v,<em style="color:transparent">本文来源[email protected]搞@^&代*@码)网9</em><strong>搞代gaodaima码</strong>$data->data[0]->seed); <BR> $one=($data->data[0]->segs->$k); <BR> if($k == 'flv' || $k == 'mp4') return "http://f.youku.com/player/getFlvPath/sid/{$sid}_00/st/{$k}/fileid/{$fileid}?K={$one[0]->k}"; <BR> continue; <BR> } <BR>} <BR>function get_curl_contents($url, $second = 5){ <BR> if(!function_exists('curl_init')) die('php.ini未开启php_curl.dll'); <BR> $c = curl_init(); <BR> curl_setopt($c,CURLOPT_URL,$url); <BR> $UserAgent=$_SERVER['HTTP_USER_AGENT']; <BR> curl_setopt($c,CURLOPT_USERAGENT,$UserAgent); <BR> curl_setopt($c,CURLOPT_HEADER,0); <BR> curl_setopt($c,CURLOPT_TIMEOUT,$second); <BR> curl_setopt($c,CURLOPT_RETURNTRANSFER, true); <BR> $cnt = curl_exec($c); <BR> $cnt=mb_check_encoding($cnt,'utf-8')?iconv('gbk','utf-8//IGNORE',$cnt):$cnt; //字符编码转换 <BR> curl_close($c); <BR> return $cnt; <BR>} <BR>function getSid() { <BR> $sid = time().(rand(0,9000)+10000); <BR> return $sid; <BR>} <BR>function getkey($key1,$key2){ <BR> $a = hexdec($key1); <BR> $b = $a ^ 0xA55AA5A5; <BR> $b = dechex($b); <BR> return $key2.$b; <BR>} <BR>function getfileid($fileId,$seed) { <BR> $mixed = getMixString($seed); <BR> $ids = explode("*",$fileId); <BR> unset($ids[count($ids)-1]); <BR> $realId = ""; <BR> for ($i=0;$i < count($ids);++$i) { <BR> $idx = $ids[$i]; <BR> $realId .= substr($mixed,$idx,1); <BR> } <BR> return $realId; <BR>} <BR>function getMixString($seed) { <BR> $mixed = ""; <BR> $source = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ/\\:._-1234567890"; <BR> $len = strlen($source); <BR> for($i=0;$i< $len;++$i){ <BR> $seed = ($seed * 211 + 30031) % 65536; <BR> $index = ($seed / 65536 * strlen($source)); <BR> $c = substr($source,$index,1); <BR> $mixed .= $c; <BR> $source = str_replace($c, "",$source); <BR> } <BR> return $mixed; <BR>} <BR>?><BR>