PPTV视频解析源码

  • 2016-11-27
  • 0
  • 0
error_reporting(0);
header('Content-Type:text/html;charset=UTF-8');
$vid = $_GET['v'];
$url = "http://player.pptvyun.com/svc/flashplayer/pl/".$vid.".swf";
$header = httpCurl($url,true);

$temp = parse_url($header);
$api = preg_replace('/swf=/','',$temp['query']);

preg_match('/o={p}(.*?)$/',urldecode($api),$o);
preg_match('/validtk={p}(.*?)&/',urldecode($api),$token);

$api = "http://svc.pptvyun.com/svc/v1/play/auth/?playStr=".$vid."&username=&type=web.cloudplay&userType%3D0%26o%3D28667&validtk=".$token[1]."&o=".$o[1]."&referrer=&type=web.cloudplay&o=".$o[1]."&pageUrl=";

header('Content-Type:application/xml;charset=utf-8');
$data=vcurl($api);

preg_match_all('|</bwt><bh>(.*?)</bh>|', $data, $c);
preg_match_all('|UTC">(.*?)</key>|', $data, $d);
preg_match_all('|<item rid="(.*?)"|', $data, $e);
switch ($_GET['qxd']) {
        case 'cq':
                $ip_ip = $c[1][1];
                $key_key = $d[1][1];
                $mp4_mp4 = $e[1][1];
                break;
         case 'gq':
                $ip_ip = $c[1][0];
                $key_key = $d[1][0];
                $mp4_mp4 = $e[1][0];
                break;       
          case 'pt':
                $ip_ip = $c[1][2];
                $key_key = $d[1][2];
                $mp4_mp4 = $e[1][2];
                break;
           case 'pq':
                $ip_ip = $c[1][3];
                $key_key = $d[1][3];
                $mp4_mp4 = $e[1][3];
                break;                                
        default:
                $ip_ip = $c[1][1];
                $key_key = $d[1][1];
                $mp4_mp4 = $e[1][1];
                break;
}


$url = "http://".$ip_ip."/w/".$mp4_mp4."?fpp.ver=1.3.0.19&k=".$key_key."&type=web.cloudplay";
header("location: {$url}");
function httpCurl($url,$returnHeader=false,$referer=NULL)
{
                $UserAgent = 'Mozilla/5.0 (iPad; CPU OS 9_2_1 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13D15 Safari/601.1';
                $curl = curl_init();
                curl_setopt($curl, CURLOPT_URL, $url);
                curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 30);
                curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
                curl_setopt($curl, CURLOPT_USERAGENT, $UserAgent);
                curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
                $data = curl_exec($curl);
                if($returnHeader){

                        $data = curl_getinfo($curl,CURLINFO_EFFECTIVE_URL);
                }
                curl_close($curl);
                return $data;
}
function vcurl($url)
{
                $curl = curl_init();
                curl_setopt($curl, CURLOPT_URL, $url);
                curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 30);
                curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
                $data = curl_exec($curl);
                curl_close($curl);
                return $data;
}

评论

还没有任何评论,你来说两句吧

CC共享许可协议:BY-NC-SA 4.0 - 友情链接 - Theme by Qzhai