解析獲取優(yōu)酷視頻真實下載地址的PHP源代碼
更新時間:2013年06月26日 12:04:22 作者:
本篇文章是對獲取優(yōu)酷視頻真實下載地址的PHP源代碼進行了詳細的分析介紹,需要的朋友參考下
復制代碼 代碼如下:
<?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未開啟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實現(xiàn)使用優(yōu)酷土豆視頻地址獲取swf播放器分享地址
- php利用騰訊ip分享計劃獲取地理位置示例分享
- PHP采集騰訊微博的實現(xiàn)代碼
- 騰訊QQ php程序員面試題目整理
- php實現(xiàn)把url轉(zhuǎn)換迅雷thunder資源下載地址的方法
- PHP中IP地址與整型數(shù)字互相轉(zhuǎn)換詳解
- 把文本中的URL地址轉(zhuǎn)換為可點擊鏈接的JavaScript、PHP自定義函數(shù)
- PHP轉(zhuǎn)換IP地址到真實地址的方法詳解
- php獲取當前頁面完整URL地址
- php將url地址轉(zhuǎn)化為完整的a標簽鏈接代碼(php為url地址添加a標簽)
- PHP實現(xiàn)將優(yōu)酷土豆騰訊視頻html地址轉(zhuǎn)換成flash swf地址的方法
相關文章
PHP實現(xiàn)字節(jié)數(shù)Byte轉(zhuǎn)換為KB、MB、GB、TB的方法
這篇文章主要介紹了PHP實現(xiàn)字節(jié)數(shù)Byte轉(zhuǎn)換為KB、MB、GB、TB的方法,結(jié)合實例形式分析了php針對字節(jié)數(shù)Byte的換算操作具體實現(xiàn)方法,涉及php數(shù)學運算相關函數(shù)的使用,需要的朋友可以參考下2017-08-08PHP PDOStatement:bindParam插入數(shù)據(jù)錯誤問題分析
PHP PDOStatement:bindParam插入數(shù)據(jù)錯誤問題分析,開發(fā)中一定要注意2013-11-11PHPWind與Discuz截取字符函數(shù)substrs與cutstr性能比較
PHP性能優(yōu)化系列第四期實戰(zhàn)篇,如何使用PEAR Benchmark類工具獲取函數(shù)執(zhí)行性能,這里以PHPWind與Discuz!兩個社區(qū)論壇的截取字符函數(shù)substrs與cutstr為例,分析兩個函數(shù)的執(zhí)行性能情況2011-12-12學習php設計模式 php實現(xiàn)備忘錄模式(Memento)
這篇文章主要介紹了php設計模式中的備忘錄模式,使用php實現(xiàn)備忘錄模式,感興趣的小伙伴們可以參考一下2015-12-12PHP中soap用法示例【SoapServer服務端與SoapClient客戶端編寫】
這篇文章主要介紹了PHP中soap用法,結(jié)合實例形式分析了SoapServer服務端與SoapClient客戶端相關實現(xiàn)技巧與操作注意事項,需要的朋友可以參考下2018-12-12