解析獲取優(yōu)酷視頻真實(shí)下載地址的PHP源代碼
更新時(shí)間:2013年06月26日 12:04:22 作者:
本篇文章是對(duì)獲取優(yōu)酷視頻真實(shí)下載地址的PHP源代碼進(jìn)行了詳細(xì)的分析介紹,需要的朋友參考下
復(fù)制代碼 代碼如下:
<?php
//--調(diào)用方法/demo.php?url=http://v.youku.com/v_show/id_XMzkyODA2NTEy.html
echo getYoukuFlv($_GET['url']);
function getYoukuFlv($url){
preg_match("#id_(.*?)\.html#",$url,$out);
$id=$out[1];
$content=get_curl_contents('http://v.youku.com/player/getPlayList/VideoIDS/'.$id);
$data=json_decode($content);
foreach($data->data[0]->streamfileids AS $k=>$v){
$sid=getSid();
$fileid=getfileid($v,$data->data[0]->seed);
$one=($data->data[0]->segs->$k);
if($k == 'flv' || $k == 'mp4') return "http://f.youku.com/player/getFlvPath/sid/{$sid}_00/st/{$k}/fileid/{$fileid}?K={$one[0]->k}";
continue;
}
}
function get_curl_contents($url, $second = 5){
if(!function_exists('curl_init')) die('php.ini未開(kāi)啟php_curl.dll');
$c = curl_init();
curl_setopt($c,CURLOPT_URL,$url);
$UserAgent=$_SERVER['HTTP_USER_AGENT'];
curl_setopt($c,CURLOPT_USERAGENT,$UserAgent);
curl_setopt($c,CURLOPT_HEADER,0);
curl_setopt($c,CURLOPT_TIMEOUT,$second);
curl_setopt($c,CURLOPT_RETURNTRANSFER, true);
$cnt = curl_exec($c);
$cnt=mb_check_encoding($cnt,'utf-8')?iconv('gbk','utf-8//IGNORE',$cnt):$cnt; //字符編碼轉(zhuǎn)換
curl_close($c);
return $cnt;
}
function getSid() {
$sid = time().(rand(0,9000)+10000);
return $sid;
}
function getkey($key1,$key2){
$a = hexdec($key1);
$b = $a ^ 0xA55AA5A5;
$b = dechex($b);
return $key2.$b;
}
function getfileid($fileId,$seed) {
$mixed = getMixString($seed);
$ids = explode("*",$fileId);
unset($ids[count($ids)-1]);
$realId = "";
for ($i=0;$i < count($ids);++$i) {
$idx = $ids[$i];
$realId .= substr($mixed,$idx,1);
}
return $realId;
}
function getMixString($seed) {
$mixed = "";
$source = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ/\\:._-1234567890";
$len = strlen($source);
for($i=0;$i< $len;++$i){
$seed = ($seed * 211 + 30031) % 65536;
$index = ($seed / 65536 * strlen($source));
$c = substr($source,$index,1);
$mixed .= $c;
$source = str_replace($c, "",$source);
}
return $mixed;
}
?>
您可能感興趣的文章:
- PHP實(shí)現(xiàn)使用優(yōu)酷土豆視頻地址獲取swf播放器分享地址
- php利用騰訊ip分享計(jì)劃獲取地理位置示例分享
- PHP采集騰訊微博的實(shí)現(xiàn)代碼
- 騰訊QQ php程序員面試題目整理
- php實(shí)現(xiàn)把url轉(zhuǎn)換迅雷thunder資源下載地址的方法
- PHP中IP地址與整型數(shù)字互相轉(zhuǎn)換詳解
- 把文本中的URL地址轉(zhuǎn)換為可點(diǎn)擊鏈接的JavaScript、PHP自定義函數(shù)
- PHP轉(zhuǎn)換IP地址到真實(shí)地址的方法詳解
- php獲取當(dāng)前頁(yè)面完整URL地址
- php將url地址轉(zhuǎn)化為完整的a標(biāo)簽鏈接代碼(php為url地址添加a標(biāo)簽)
- PHP實(shí)現(xiàn)將優(yōu)酷土豆騰訊視頻html地址轉(zhuǎn)換成flash swf地址的方法
相關(guān)文章
PHP實(shí)現(xiàn)字節(jié)數(shù)Byte轉(zhuǎn)換為KB、MB、GB、TB的方法
這篇文章主要介紹了PHP實(shí)現(xiàn)字節(jié)數(shù)Byte轉(zhuǎn)換為KB、MB、GB、TB的方法,結(jié)合實(shí)例形式分析了php針對(duì)字節(jié)數(shù)Byte的換算操作具體實(shí)現(xiàn)方法,涉及php數(shù)學(xué)運(yùn)算相關(guān)函數(shù)的使用,需要的朋友可以參考下2017-08-08PHP PDOStatement:bindParam插入數(shù)據(jù)錯(cuò)誤問(wèn)題分析
PHP PDOStatement:bindParam插入數(shù)據(jù)錯(cuò)誤問(wèn)題分析,開(kāi)發(fā)中一定要注意2013-11-11PHPWind與Discuz截取字符函數(shù)substrs與cutstr性能比較
PHP性能優(yōu)化系列第四期實(shí)戰(zhàn)篇,如何使用PEAR Benchmark類(lèi)工具獲取函數(shù)執(zhí)行性能,這里以PHPWind與Discuz!兩個(gè)社區(qū)論壇的截取字符函數(shù)substrs與cutstr為例,分析兩個(gè)函數(shù)的執(zhí)行性能情況2011-12-12學(xué)習(xí)php設(shè)計(jì)模式 php實(shí)現(xiàn)備忘錄模式(Memento)
這篇文章主要介紹了php設(shè)計(jì)模式中的備忘錄模式,使用php實(shí)現(xiàn)備忘錄模式,感興趣的小伙伴們可以參考一下2015-12-12PHP中soap用法示例【SoapServer服務(wù)端與SoapClient客戶端編寫(xiě)】
這篇文章主要介紹了PHP中soap用法,結(jié)合實(shí)例形式分析了SoapServer服務(wù)端與SoapClient客戶端相關(guān)實(shí)現(xiàn)技巧與操作注意事項(xiàng),需要的朋友可以參考下2018-12-12