php

位置:IT落伍者 >> php >> 浏览文章

解析获取优酷视频真实下载地址的PHP源代码


发布日期:2019年10月18日
 
解析获取优酷视频真实下载地址的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;
}
?>

               

上一篇:计算php页面运行时间的函数介绍

下一篇:php 邮箱,网址,手机号码合法性正则