奇藝的解析源碼,此源碼為老版本的源碼,但是還是可以使用~!可以自己加緩存哦~!嘿嘿就行號非常耗自己服務(wù)請求帶寬,這個就需要各位兄弟怎么去設(shè)置~!很簡單修改里面的某個參數(shù)即可~!
更多源碼請關(guān)注QQ群:516722628
- <?php
- define('NAME_PATH', 'data/name/'); //文件名稱的目錄
- define('COOKIE_IQIYI','P00001=');
- header('Pragma:no-cache');
- header("Expires:-1");
- $url = $_GET['url'];
-
- $html = file_get_contents($url);
- //preg_match('##',$html,$bool);
- preg_match('#\"tvId\":(.*?),#',$html,$tvid);
- preg_match('#\"vid\":\"(.*?)\",#',$html,$vids);
- $member = '';//是否為付費視頻
- $vid = $vids[1];
- $tvid = $tvid[1];
-
- $t = time()*1000;
- $src = "76f90cbd92f94a2e925d83e8ccd22cb7";
- $key = "d5fb4bd9d50c4be6948c97edd7254b0e";
- $sc = md5($t.$key.$vid);
- $url = "http://cache.m.iqiyi.com/jp/tmts/$tvid/$vid/?t=$t&sc=$sc&src=$src";
-
- $content = curl($url,COOKIE_IQIYI);
- $content = preg_replace("#var tvInfoJs=#","",$content);
-
- $json = json_decode($content,true);
- $data = $json['data'];
- $vidl = $data['vidl'];
- foreach($vidl as $key => $value){
- $type = $value['vd'];
- if($type==14||$type==17||$type==21||$type==1||$type==96){//過濾 H265(m3u8不支持h265編碼格式)和低畫質(zhì)視頻(流暢 標(biāo)清)
- continue;
- }
- $m3u = $value['m3u'];
- }
- $url = $m3u;
- function is_ipad() {
- $user_agent = strtolower($_SERVER['HTTP_USER_AGENT']); //獲取瀏覽器信息
- preg_match("#(ipad|iphone|mac|ios|linux|android|ipod)#", $user_agent, $bool);
- $isiPad = empty($bool[1]) ? false : true; //是否為移動端
- return $isiPad;
- }
- function curl($url, $cookie = "") {
- $params["ua"] = "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.84 Safari/537.36";
- $params["ip"] = "14.21.98.117";//偽裝為固定IP,否則會報異地登錄,會封號,不要更改
- $params["cookie"] = $cookie;
- $params["ref"] = "https://www.iqiyi.com";
- //$params["proxy"] = PROXY;
- return iqiyi_curl($url,$params);
- }
- function iqiyi_curl($url, $params = array()) {
- $ip = empty($params["ip"]) ? rand_ip() : $params["ip"];
- $header = array('X-FORWARDED-FOR:'.$ip,'CLIENT-IP:'.$ip);
- if(isset($params["httpheader"])){
- $header = array_merge($header,$params["httpheader"]);
- }
- $referer = empty($params["ref"]) ? $url : $params["ref"];
- $user_agent = empty($params["ua"]) ? $_SERVER['HTTP_USER_AGENT'] : $params["ua"] ;
-
- $ch = curl_init(); //初始化 curl
- curl_setopt($ch, CURLOPT_URL, $url); //要訪問網(wǎng)頁 URL 地址
- curl_setopt($ch, CURLOPT_HTTPHEADER, $header); //偽裝來源 IP 地址
- curl_setopt($ch, CURLOPT_REFERER, $referer); //偽裝網(wǎng)頁來源 URL
- curl_setopt($ch, CURLOPT_USERAGENT,$user_agent); //模擬用戶瀏覽器信息
- curl_setopt($ch, CURLOPT_NOBODY, false); //設(shè)定是否輸出頁面內(nèi)容
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); //返回字符串,而非直接輸出到屏幕上
- curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, false); //連接超時時間,設(shè)置為 0,則無限等待
- curl_setopt($ch, CURLOPT_TIMEOUT, 3600); //數(shù)據(jù)傳輸?shù)淖畲笤试S時間超時,設(shè)為一小時
- curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY); //HTTP驗證方法
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); //不檢查 SSL 證書來源
- curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); //不檢查 證書中 SSL 加密算法是否存在
- curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); //跟蹤爬取重定向頁面
- curl_setopt($ch, CURLOPT_AUTOREFERER, true); //當(dāng)Location:重定向時,自動設(shè)置header中的Referer:信息
- curl_setopt($ch, CURLOPT_ENCODING, ''); //解決網(wǎng)頁亂碼問題
- curl_setopt($ch, CURLOPT_HEADER, empty($params["header"])?false:true); //不返回 header 部分
- if(!empty($params["fields"])){
- curl_setopt($ch, CURLOPT_POST, true); //設(shè)置為 POST
- curl_setopt($ch, CURLOPT_POSTFIELDS,$params["fields"]); //提交數(shù)據(jù)
- }
- if(!empty($params["cookie"])){
- curl_setopt($ch, CURLOPT_COOKIE, $params["cookie"]); //從字符串傳參來提交cookies
- }
- if(!empty($params["proxy"])){
- curl_setopt($ch, CURLOPT_PROXYAUTH, CURLAUTH_BASIC); //代理認(rèn)證模式
- curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_HTTP); //使用http代理模式
- curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, 1);
- curl_setopt($ch, CURLOPT_PROXY, "58.251.230.220:9797"); //代理服務(wù)器地址 host:post的格式
-
- if(!empty($params["proxy_userpwd"])){
- curl_setopt($ch, CURLOPT_PROXYUSERPWD, $params["proxy_userpwd"]); //http代理認(rèn)證賬號,username:password的格式
- }
- }
- $data = curl_exec($ch); //運行 curl,請求網(wǎng)頁并返回結(jié)果
- curl_close($ch); //關(guān)閉 curl
- return $data;
- }
- function rand_ip() {
- $ip_long = array(array('607649792', '608174079'), //36.56.0.0-36.63.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('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, 9);
- $ip = long2ip(mt_rand($ip_long[$rand_key][0], $ip_long[$rand_key][1]));
- return $ip;
- }
- $wap = preg_match("/(iPhone|iPad|iPod|Linux|Android)/i", strtoupper($_SERVER['HTTP_USER_AGENT']));
- if($wap){
- $datainfo['success'] = '1';
- $datainfo['type'] = '';
- $datainfo['play'] = 'h5mp4';
- $datainfo['url'] = $url;
- }else{
- $datainfo['success'] = '1';
- $datainfo['type'] = '';
- $datainfo['play'] = 'hls';
- $datainfo['url'] = $url;
- }
-
- $json_data=json_encode($datainfo);
- echo $json_data;
- ?>