龙珠解析源码

资源分享龙珠解析源码

龙珠解析源码

  1. <?php   
  2.   
  3. echo json_encode(LongZhu::parse($url));  
  4.   
  5. /** 
  6.  
  7. */  
  8. class LongZhu  
  9. {  
  10.   
  11.     public static function parse($url)  
  12.     {  
  13.         $vid = explode(“?"basename($url))[0];  
  14.         $data = self::get_video_url($vid);  
  15.         if(!emptyempty($data)){  
  16.             return $data;  
  17.         }else{  
  18.             $content = self::curl($url);  
  19.             preg_match('#“RoomId":(.*?),#’,$content,$_rid);  
  20.             if(!emptyempty($_rid[1])){  
  21.                 $rid = $_rid[1];  
  22.             }else{  
  23.                 preg_match(“#ROOMID\s*=\s*'(.*?)’;#",$content,$__rid);  
  24.                 $rid = $__rid[1];  
  25.             }  
  26.             return self::get_live_url($rid);  
  27.         }  
  28.     }  
  29.     public static function get_video_url($mid)  
  30.     {  
  31.         $api = “http://api.v.plu.cn/CloudMedia/GetInfoForPlayer?mediaId={$mid}";  
  32.         $content = self::curl($api);  
  33.         $data = json_decode($content,true);  
  34.         if(!emptyempty($data[“urls"])){  
  35.             $urls = $data[“urls"];  
  36.             foreach ($urls as $key => $value) {  
  37.                 $level = $value[“RateLevel"];  
  38.                 $ext = $value[“Ext"];  
  39.                 $vurl = $value[“SecurityUrl"];  
  40.                 switch ($level) {  
  41.                     case 1:$def=“标清";break;  
  42.                     case 2:$def=“高清";break;  
  43.                     case 3:$def=“超清";break;  
  44.                     case 4:$def=“原画";break;  
  45.                     default:$def=“自动";break;  
  46.                 }  
  47.                 switch ($ext) {  
  48.                     case 'flv’:$type = “flv";break;  
  49.                     case 'mp4’:$type = “mp4";break;  
  50.                     case 'm3u8’:$type = “m3u8";break;  
  51.                 }  
  52.                 if (GlobalBase::is_ipad()) {  
  53.                     if($ext==’m3u8′){  
  54.                         $videoinfo['code’] = 200;  
  55.                         $videoinfo[“data"][“video"][“file"] = $vurl;  
  56.                         $videoinfo[“data"][“video"][“type"] = “video/m3u8";  
  57.                         break;  
  58.                     }  
  59.                 }else{  
  60.                     $video[0] = $vurl;  
  61.                     $video[1] = $type;  
  62.                     $video[2] = $type.$def;  
  63.                     $video[3] =  $level != 2 ? 0 : 10;  
  64.                     $videoinfo[“code"] = 200;  
  65.                     $videoinfo[“data"][“video"][$key] = $video;  
  66.                     $videoinfo[“data"][“flashplayer"] = true;  
  67.                 }  
  68.             }  
  69.             return $videoinfo;  
  70.         }else{  
  71.             return “";  
  72.         }  
  73.     }  
  74.     public static function get_live_url($rid)  
  75.     {  
  76.         $api = “http://liveapi.plu.cn/liveapp/roomstatus?roomId={$rid}";  
  77.         $content = self::curl($api);  
  78.         $data = json_decode($content,true);  
  79.         $img = $data[“cover"];  
  80.         $vurl = $data[“streamUri"];  
  81.         $videoinfo[“poster"] = $img;      
  82.         if (!GlobalBase::is_ipad()) {  
  83.             $videoinfo[“data"][“live"] = true;  
  84.             $videoinfo[“data"][“flashplayer"] = true;  
  85.         }  
  86.         $videoinfo['code’] = 200;  
  87.         $videoinfo[“data"][“video"][“file"] = $vurl;  
  88.         $videoinfo[“data"][“video"][“type"] = “video/m3u8";  
  89.         return $videoinfo;  
  90.     }  
  91.     public static function curl($url)  
  92.     {  
  93.         $params[“ua"] = “Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.84 Safari/537.36";  
  94.         return GlobalBase::curl($url,$params);  
  95.     }  
  96. }  
  97.  ?>  

Posted by 柴郡猫