乐视解析源码

资源分享乐视解析源码

乐视解析源码

  1. <?php  
  2. $id = Le::parse($url);  
  3. $video_info = Le::parseVideoUrl($id);  
  4. echo json_encode($video_info);  
  5. /** 
  6.  
  7. */  
  8. class Le  
  9. {  
  10.     public static function parse($url)  
  11.     {  
  12.         preg_match('#vplay/(.*?).htm#’,$url,$ids);  
  13.         if ($ids[1]) {  
  14.             $name = “LE-“.md5($ids[1]);  
  15.         }else{  
  16.             $name = “LE-“.md5($url);  
  17.         }  
  18.   
  19.         if (file_exists(NAME_PATH.$name)) {  
  20.             $data = json_decode(file_get_contents(NAME_PATH.$name),true);  
  21.             $pay = $data['pay’];  
  22.             $vid = $data['vid’];  
  23.             $title = $data['title’];  
  24.             $poster = $data['poster’];  
  25.         }else{  
  26.             $content = self::curl($url);  
  27.             preg_match('#vid: (.*?),#’,$content,$vids);  
  28.             preg_match('#title:“(.*?)",#’,$content,$titles);  
  29.             preg_match('#videoPic:“(.*?)",#’,$content,$pics);  
  30.             preg_match('#isPay: (.*?),#’,$content,$isPay);  
  31.             $vid = $vids[1];  
  32.             $title = $titles[1];  
  33.             $poster = !emptyempty($pics[1]) ? str_replace('320_200′,’640_320’,$pics[1]) : ";  
  34.             $pay = $isPay[1];//是否付费  
  35.             file_put_contents(NAME_PATH.$name, json_encode(array(“vid"=>$vid,“pay"=>$pay,“title"=>$title,“poster"=>$poster)));  
  36.         }  
  37.         return $vid;  
  38.     }  
  39.     public static function parseVideoUrl($vid){  
  40.         $time = number_format(microtime(true),3,'.’,");   
  41.         $tkey = self::getMmsKey($time);  
  42.         $tss = GlobalBase::is_ipad() ? “no" : “ios";  
  43.         $splatid = GlobalBase::is_ipad() ? 107 : 105;  
  44.         $domain = GlobalBase::is_ipad() ? 'm.le.com’ : 'www.le.com’;  
  45.         $source = GlobalBase::is_ipad() ? '1001’ : '1000’;  
  46.         //$url = “http://player-pc.le.com/mms/out/video/playJson?id={$vid}&format=1&tkey={$tkey}&domain=www.le.com&dvtype=1000&region=cn&accessyx=1&platid=3&splatid=304&source=1000&tss=no";  
  47.         $url = “http://player-pc.le.com/mms/out/video/playJson?id={$vid}&platid=1&splatid={$splatid}&format=1&tkey={$tkey}&domain={$domain}&dvtype=720p&devid=70A6E0A1FB93DA437B79DA594B3C9D03B428043B&region=cn&source={$source}&accessyx=1&tss={$tss}";//&tss=tvts  
  48.   
  49.         $data = self::curl($url);  
  50.         //print_r($data);exit;  
  51.         $content = json_decode($data,true);  
  52.         $playurl = $content[“msgs"][“playurl"];  
  53.         $point = $content[“msgs"][“point"];  
  54.         $hot = $point[“hot"];  
  55.         $seek = $point[“skip"][0];  
  56.   
  57.         $pic = $playurl[“picAll"][“640*320"];  
  58.         $domains = array(“http://play.g3proxy.lecloud.com",“http://bplay.g3proxy.lecloud.com",“http://g3.letv.com");  
  59.         $domain = $domains[0];//$domains[mt_rand(0,count($domains)-1)];  
  60.         $dispatch = $playurl[“dispatch"];  
  61.         $duration = $playurl[“duration"];  
  62.         foreach ($dispatch as $key => $value) {  
  63.             switch ($key) {  
  64.                 case '350’:$def = “流畅";break;  
  65.                 case '1000’:$def = “超清";break;  
  66.                 case '1300’:$def = “原画";break;  
  67.                 case '720p’:$def = “720P";break;  
  68.                 case '1080p’:$def = “1080P";break;  
  69.             }  
  70.             $vurl = $domain.$value[0];//self::getVideoUrl($domain.$value[0]."&format=1&expect=3&sign=letv"); //&format=1为json &format=1为xml  preg_replace(“#/vod/v2/#","/  
  71.   
  72.             if (GlobalBase::is_ipad()) {  
  73.                 if($key =="1000“){ 
  74.                     $videoinfo['code’] = 200; 
  75.                     //$videoinfo['type’] = 'le’; 
  76.                     //$videoinfo['play’] = 'h5mp4’; 
  77.                     $videoinfo[“data“][“url“] = $vurl; 
  78.                     return $videoinfo;exit; 
  79.                 } 
  80.             }else{ 
  81.                 if ($key == '1300’ && $vurl != ") { 
  82.                     $fdata[0]['url’] = $vurl; 
  83.                     $fdata[0]['def’] = '原画’; 
  84.                 }  
  85.                 if ($key == '1080p’ && $vurl != ") { 
  86.                     $fdata[1]['url’] = $vurl; 
  87.                     $fdata[1]['def’] = '1080P’; 
  88.                 } 
  89.                 if ($key == '1000’ && $vurl != ") { 
  90.                     $fdata[2]['url’] = $vurl; 
  91.                     $fdata[2]['def’] = '超清’; 
  92.                 } 
  93.                 if ($key == '720p’ && $vurl != ") { 
  94.                     $fdata[3]['url’] = $vurl; 
  95.                     $fdata[3]['def’] = '720P’; 
  96.                 } 
  97.                 if ($key == '350’ && $vurl != ") { 
  98.                     $fdata[4]['url’] = $vurl; 
  99.                     $fdata[4]['def’] = '流畅’; 
  100.                 } 
  101.             } 
  102.         } 
  103.         for ($i=0; $i <= 10 ; $i++) {  
  104.             if ($fdata[$i] == ") {continue;} 
  105.             $key_arrays[]=$fdata[$i]; 
  106.         } 
  107.         $videoinfo['code’] = 200; 
  108.         $videoinfo['poster’] = $img; 
  109.         $videoinfo['name’] = $video_info[“coreVideoInfo“][“videoName“]; 
  110.         $videoinfo['play’] = "; 
  111.         $videoinfo[“data“][“video“][“file“] = $key_arrays[0]['url’]; 
  112.         $videoinfo[“data“][“video“][“type“] = “video/m3u8“; 
  113.         return $videoinfo; 
  114.     } 
  115.     public static function curl($url,$cookie="“) 
  116.     { 
  117.         $params[“ua“] = “Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.84 Safari/537.36“; 
  118.         $params[“cookie“] = $cookie; 
  119.         return GlobalBase::curl($url,$params); 
  120.     } 
  121.     //==================================================以下代码不需要修改========================================================== 
  122.     /** 
  123.      * [getVideoUrl 获取视频最终地址] 
  124.      * @param  [type] $url [description] 
  125.      * @return [type]      [description] 
  126.      */ 
  127.     private static function getVideoUrl($url){ 
  128.         $data = GlobalBase::curl($url); 
  129.         $content = json_decode($data,true); 
  130.         $location = $content[“location“]; 
  131.         $nodelist = $content[“nodelist“]; 
  132.         $vurl = $nodelist[mt_rand(0,count($nodelist)-1)][“location“]; 
  133.         return $location; 
  134.     } 
  135.     //========================================= 方式二 ================================================= 
  136.     /** 
  137.      * [getMmsKey 获取tkey] 
  138.      * @param  [type] $e [时间] 
  139.      * @return [type]    [description] 
  140.      */ 
  141.     private static function getMmsKey($e) 
  142.     { 
  143.         $t = 185025305; 
  144.         $r = 8; 
  145.         $n = $e; 
  146.         $n = self::rotateRight($n, $r); 
  147.         $o = self::s2v(“O“,$n, $t); 
  148.         return $o; 
  149.     } 
  150.     private static function rotateRight($e, $t) 
  151.     { 
  152.         for ($r, $n = 0; self::s2v(“g“,$t, $n); $n++){ 
  153.             $r = self::s2v(“o",1,$e);  
  154.             $e >>= 1;  
  155.             $r <<= 31;  
  156.             $e += $r;  
  157.         }  
  158.         return $e;  
  159.     }  
  160.     private static function s2v($k,$y,$r){  
  161.         switch ($k) {  
  162.             case 'D’:return $y | $r;break;  
  163.             case 'd’:return $y % $r;break;  
  164.             case 'O’:return $y ^ $r;break;  
  165.             case 'k’:return $y < $r;break;  
  166.             case 'J’:return $y >> $r;break;  
  167.             case 'R’:return $y === $r;break;  
  168.             case 'g’:return $y > $r;break;  
  169.             case 'o’:return $y & $r;break;  
  170.             case 'l’:return $y !== $r;break;  
  171.             case 'L’:return $y != $r;break;  
  172.             case 'a’:return $y – $r;break;  
  173.             case 'u’:return $y == $r;break;  
  174.             case 'e’:return $y << $r;break;  
  175.         }  
  176.     }  
  177. }  
  178. ?>  

Posted by 柴郡猫