熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> PHP編程 >> 正文

解析獲取優酷視頻真實下載地址的PHP源代碼

2022-06-13   來源: PHP編程 

  代碼如下:
<?php
//調用方法/demophp?url=
echo getYoukuFlv($_GET[url]);

function getYoukuFlv($url){
preg_match("#id_(*?)html#"$url$out);
$id=$out[];
$content=get_curl_contents($id);
$data=json_decode($content);
foreach($data>data[]>streamfileids AS $k=>$v){
$sid=getSid();
$fileid=getfileid($v$data>data[]>seed);
$one=($data>data[]>segs>$k);
if($k == flv || $k == mp) return "{$sid}_/st/{$k}/fileid/{$fileid}?K={$one[]>k}";
continue;
}
}
function get_curl_contents($url $second = ){
if(!function_exists(curl_init)) die(phpini未開啟php_curldll);
$c = curl_init();
curl_setopt($cCURLOPT_URL$url);
$UserAgent=$_SERVER[HTTP_USER_AGENT];
curl_setopt($cCURLOPT_USERAGENT$UserAgent);
curl_setopt($cCURLOPT_HEADER);
curl_setopt($cCURLOPT_TIMEOUT$second);
curl_setopt($cCURLOPT_RETURNTRANSFER true);
$cnt = curl_exec($c);
$cnt=mb_check_encoding($cntutf)?iconv(gbkutf//IGNORE$cnt):$cnt; //字符編碼轉換
curl_close($c);
return $cnt;
}
function getSid() {
$sid = time()(rand()+);
return $sid;
}
function getkey($key$key){
$a = hexdec($key);
$b = $a ^ xAAAA;
$b = dechex($b);
return $key$b;
}
function getfileid($fileId$seed) {
$mixed = getMixString($seed);
$ids = explode("*"$fileId);
unset($ids[count($ids)]);
$realId = "";
for ($i=;$i < count($ids);++$i) {
$idx = $ids[$i];
$realId = substr($mixed$idx);
}
return $realId;
}
function getMixString($seed) {
$mixed = "";
$source = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ/:_";
$len = strlen($source);
for($i=;$i< $len;++$i){
$seed = ($seed * + ) % ;
$index = ($seed / * strlen($source));
$c = substr($source$index);
$mixed = $c;
$source = str_replace($c ""$source);
}
return $mixed;
}
?>


From:http://tw.wingwit.com/Article/program/PHP/201311/20940.html
    推薦文章
    Copyright © 2005-2022 電腦知識網 Computer Knowledge   All rights reserved.