好东西又来了,通过优酷链接获取优酷真实视频地址,需要的朋友可以拿去研究下,已测试过
更多技术文章请移步
http://www.dahuzhi.com<?php <br />
<br>
/*<br>
返回:<br>
数组<br>
'mp4'=> 字符串“http://f.youku.com/player/getFlvPath/sid/138041779515547_00/st/mp4/fileid/03000804005241236C2C5300422C39EBED4FE4-2CCC-71BB-6AC3-59B4332828D7?K=48daa690020 23a2a2828f4f1'(长度=167)<br>
'flv'=> 字符串“http://f.youku.com/player/getFlvPath/sid/138041779514451_00/st/flv/fileid/030002040052410FA52C5300422C39EBED4FE4-2CCC-71BB-6AC3-59B4332828D7?K=b9c1dfedde4eb5 052828f4f1'(长度=167)<br>
*/<br>
<br>
if(YoukuFlv::getYoukuFlv("http://v.youku.com/v_show/id_XNjEyOTE4NTEy_ev_1.html"))<br>
{<br>
var_dump( YoukuFlv::result() );<br>
}<br>
其他<br>
{<br>
echo YoukuFlv::error();<br>
}<br>
<br>
<br>
<br>
/*<br>
获取优酷视频地址 <br>
*/<br>
类 YoukuFlv{<br>
<br>
静态私人$错误= "";<br>
静态私有$结果= array();<br>
<br>
静态公共函数 getYoukuFlv($url){<br>
//从url获取youkuid<br>
if(!$id = self::getYoukuId($url)){<br>
返回 false;<br>
}<br>
//获取优酷视频详细信息<br>
$content = self::get_curl_contents( "http://v.youku.com/player/getPlayList/VideoIDS/".$id );<br>
$data = json_decode($content);<br>
if(!isset($data->data[0]->streamfileids)){<br>
self::$error = “找不到此视频”;<br>
返回 false;<br>
}<br>
foreach($data->data[0]->streamfileids AS $k=>$v){<br>
if($k == 'flv' || $k == 'mp4'){ <br>
//sid<br>
$sid= self::getSid();<br>
//文件ID<br>
$fileid = self::getfileid($v,$data->data[0]->seed);<br>
$one=($data->data[0]->segs->$k);<br>
self::$result[$k] = "http://f.youku.com/player/getFlvPath/sid/{$sid}_00/st/{$k}/fileid/{$fileid}?K={ $one[0]->k}";<br>
}<br>
}<br>
if(空(self::$结果)){<br>
self::$error = “此视频不是 MP4 或 FLV 格式”;<br>
返回 false;<br>
}其他{<br>
返回 true;<br>
}<br>
} <br>
静态公共函数错误(){<br>
返回自我::$错误;<br>
}<br>
<br>
静态公共函数结果(){<br> 返回自我::$结果;<br>
}<br>
<br>
静态私有函数 getYoukuId($url){ <br>
//url不能为空<br>
if($url == "" || substr($url , 0 , 29) != "http://v.youku.com/v_show/id_"){<br>
self::$error = “网址错误”;<br>
返回 false;<br>
}<br>
返回 substr($url, 29, -5); <br>
}<br>
<br>
静态私有函数 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>
curl_close($c);<br>
返回 $cnt;<br>
}<br>
静态私有函数 getSid(){<br>
$sid = time().(rand(0,9000) 10000);<br>
返回 $sid;<br>
}<br>
静态私有函数 getfileid($fileId,$seed) {<br>
$mixed = self::getMixString($seed);<br>
$ids = 爆炸("*",$fileId);<br>
未设置($ids[count($ids)-1]);<br>
$realId = "";<br>
for ($i=0;$i
$idx = $ids[$i];<br>
$realId .= substr($mixed,$idx,1);<br>
}<br>
返回 $realId;<br>
}<br>
静态私有函数 getMixString($seed) {<br>
$mixed = "";<br>
$source = “abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ/\:._-1234567890”;<br>
$len = strlen($source);<br>
for($i=0;$i
$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>
返回$mixed;<br>
}<br>
}<br>
<br>
<br>
<br>
<br>?>
AD:真正免费,域名 虚机 企业邮箱=0元