源码演示地址(不包含播放器):
[rihide]
<?php
/**
* @代码开源,透明,请勿用于商业用途,完全开源模式,供大家一起探讨研究
*
* @注释 要主播在线才可以
*
* @调用举例:http://域名/acfun.php?url=https://www.acfun.cn/bangumi/aa5024876
* @author www.5mrk.com
* @copyright 2020-06-14
* @version 0.0.1
*
* for ray-p2p btjson
*
*/
if(version_compare(PHP_VERSION,'5.6.0','<')){exit('请升级当前PHP环境,本版本解析需PHP5.6以上版本支持!');}
header('Content-type: text/json;charset=utf-8');
/*************************处理URL,判断参数**********************************/
$protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443) ? "https://" : "http://";
$_SERVER['PHP_SELF'] = '/';
$page_url = $protocol.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'].'?'.$_SERVER['QUERY_STRING'];
$url_arr = explode('url=', $page_url);
$url = $url_arr[1];
if(count($url_arr) > 2){
$url = $url_arr[1].'url='.$url_arr[2];
}
/**********************处理URL,判断参数 end*************************************/
$h2_vinfo = [];
$h2_vinfo['v_cookie'] = '';
$h2_vinfo['wxua'] = 'Mozilla/5.0 (Linux; Android 9; ONEPLUS A5000 Build/PKQ1.180716.001; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/73.0.3683.90 Mobile Safari/537.36 MicroMessenger/7.0.8.1540(0x27000834) Process/appbrand0 NetType/WIFI Language/zh_CN ABI/arm64';
$h2_vinfo['pcua'] = 'Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36';
$h2_vinfo['iosua'] = 'Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_3_3 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8J2 Safari/6533.18.5';
$h2_vinfo['padua'] = 'Mozilla/5.0 (iPad; U; CPU OS 4_2_1 like Mac OS X; zh-cn) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8C148 Chrome/69.0.3497.100 Safari/6533.18.5';
$url = str_replace("http://","https://",$url);
$h2_vinfo['url'] = $url;
$h2_vid = md5($h2_vinfo['url']);
$page_html = get_curl_ac($url,0,0,$h2_vinfo['v_cookie'],0,0,0,1);
if(strpos($page_html, 'window.pageInfo = window.videoInfo') !== false){
$page_vinfo = inter($page_html, 'window.pageInfo = window.videoInfo', 'window.videoResource');
}else{
$page_vinfo = inter($page_html, 'window.pageInfo = window.bangumiData', 'window.videoResource');
}
$page_vinfo = inter($page_vinfo, ' = ', '};');
if($page_vinfo){
$page_vinfo .= '}';
}
$page_vinfo = str_replace(" ","",$page_vinfo);
$page_vinfo_arr = json_decode($page_vinfo,1);
$play_vinfo = json_decode($page_vinfo_arr['currentVideoInfo']['ksPlayJson'],1);
$vurl = $play_vinfo['adaptationSet']['representation'][0]['url'];
if(mb_substr($vurl,0,2) == '//'){
$vurl = 'https:'.$vurl;
}
if(!empty($vurl)){
$jxre_arr = [];
$jxre_arr['code'] = 200;
$jxre_arr['url'] = $vurl;
}else{
$jxre_arr = [];
$jxre_arr['code'] = -200;
$jxre_arr['data'] = null;
}
$h2_jxre_json = json_encode($jxre_arr,1);
print_r($h2_jxre_json);
exit;
function get_curl_ac($url,$post=0,$referer=0,$cookie=0,$header=0,$ua=0,$nobaody=0,$randip=0){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
$httpheader[] = "Accept:application/json, text/javascript, */*; q=0.01";
$httpheader[] = "Accept-Encoding:gzip,deflate,sdch";
$httpheader[] = "Accept-Language:zh-CN,zh;q=0.8";
$httpheader[] = "Connection:close";
$httpheader[] = "x-requested-with: XMLHttpRequest";
if($randip == 1){
$rand_ip = get_rand_ip();
$httpheader[] = "X-FORWARDED-FOR:".$rand_ip;
$httpheader[] = "CLIENT-IP:".$rand_ip;
}
curl_setopt($ch, CURLOPT_HTTPHEADER, $httpheader);
if($post){
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
}
if($header){
curl_setopt($ch, CURLOPT_HEADER, TRUE);
}
if($cookie){
curl_setopt($ch, CURLOPT_COOKIE, $cookie);
}
if($referer){
curl_setopt($ch, CURLOPT_REFERER, $referer);
}
if($ua){
curl_setopt($ch, CURLOPT_USERAGENT,$ua);
}else{
curl_setopt($ch, CURLOPT_USERAGENT,'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.152 Safari/537.36');
}
if($nobaody){
curl_setopt($ch, CURLOPT_NOBODY,1);
}
curl_setopt($ch, CURLOPT_TIMEOUT, 15);
curl_setopt($ch, CURLOPT_ENCODING, "gzip");
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
$ret = curl_exec($ch);
curl_close($ch);
return $ret;
}
function get_rand_ip(){
$ip_long = array(
array('607649792', '608174079'), //36.56.0.0-36.63.255.255
array('975044608', '977272831'), //58.30.0.0-58.63.255.255
array('999751680', '999784447'), //59.151.0.0-59.151.127.255
array('1019346944', '1019478015'), //60.194.0.0-60.195.255.255
array('1038614528', '1039007743'), //61.232.0.0-61.237.255.255
array('1783627776', '1784676351'), //106.80.0.0-106.95.255.255
array('1947009024', '1947074559'), //116.13.0.0-116.13.255.255
array('1987051520', '1988034559'), //118.112.0.0-118.126.255.255
array('2035023872', '2035154943'), //121.76.0.0-121.77.255.255
array('2078801920', '2079064063'), //123.232.0.0-123.235.255.255
array('-1950089216', '-1948778497'), //139.196.0.0-139.215.255.255
array('-1425539072', '-1425014785'), //171.8.0.0-171.15.255.255
array('-1236271104', '-1235419137'), //182.80.0.0-182.92.255.255
array('-770113536', '-768606209'), //210.25.0.0-210.47.255.255
array('-569376768', '-564133889'), //222.16.0.0-222.95.255.255
);
$rand_key = mt_rand(0, 14);
$huoduan_ip= long2ip(mt_rand($ip_long[$rand_key][0], $ip_long[$rand_key][1]));
return $huoduan_ip;
}
function inter($str, $start, $end)
{
$wd2 = '';
if ($str && $start) {
$arr = explode($start, $str);
if (count($arr) > 1) {
$wd = $arr[1];
if ($end) {
$arr2 = explode($end, $wd);
if (count($arr2) > 1) {
$wd2 = $arr2[0];
} else {
$wd2 = $wd;
}
} else {
$wd2 = $wd;
}
}
}
return $wd2;
}
?>
[/rihide]
© 版权声明
THE END
- 最新
- 最热
只看作者