音悦台解析源码

资源分享音悦台解析源码

音悦台解析源码

  1. <?php   
  2. echo json_encode(Yinyuetai::parse($url));  
  3. /** 
  4.  
  5. */  
  6. class Yinyuetai  
  7. {  
  8.   
  9.     /** 
  10.      * [parse 解析网页获取视频ID] 
  11.      * @param  [type] $url  [description] 
  12.      * @return [type]       [description] 
  13.      */  
  14.     public static function parse($url)  
  15.     {  
  16.         $html = self::curl($url);  
  17.   
  18.         $vids = $aids = $titles = array();  
  19.         if ($html){  
  20.             preg_match('#id : “([\d]+)"#iU’,$html,$vids);  
  21.             $vid = $vids[1];  
  22.             $data = self::get_video_info($vid);  
  23.             return $data;  
  24.         }  
  25.     }  
  26.     public static function get_video_urls($vid)  
  27.     {  
  28.         $api_video = “http://www.yinyuetai.com/api/info/get-video-urls?videoId={$vid}";  
  29.         $content = GlobalBase::curl($api_video);  
  30.         print_r($api_video);exit;  
  31.         $data = json_decode($content,true);  
  32.         $hd = $data[“hdVideoUrl"];//高清  
  33.         $hc = $data[“hcVideoUrl"];//流畅  
  34.         $he = $data[“heVideoUrl"];//超清  
  35.         if (GlobalBase::is_ipad()) {  
  36.             $videoinfo[“video"][“file"] = $hd;  
  37.             $videoinfo[“video"][“type"] = “video/mp4";  
  38.         }else{  
  39.             $videoinfo[“video"][0] = array($hd,“video/mp4",“高清",10);  
  40.             $videoinfo[“video"][1] = array($he,“video/mp4",“超清",0);  
  41.             $videoinfo[“video"][2] = array($hc,“video/mp4",“流畅",0);  
  42.         }  
  43.         return $videoinfo;  
  44.     }  
  45.     public static function get_mv_info($vid)  
  46.     {  
  47.         $api_video = “http://ext.yinyuetai.com/main/get-h-mv-info?json=true&videoId={$vid}";  
  48.         $content = self::curl($api_video);  
  49.         print_r($content);exit;  
  50.         $data = json_decode($content,true);  
  51.         $video_info = $data[“videoInfo"];  
  52.         $coreVideoInfo = $video_info[“coreVideoInfo"];  
  53.         $img = $coreVideoInfo[“bigHeadImage"];  
  54.         $videoUrlModels = $coreVideoInfo[“videoUrlModels"];  
  55.         foreach ($videoUrlModels as $key => $value) {  
  56.             $def = $value[“qualityLevel"];  
  57.             $defname = $value[“qualityLevelName"];  
  58.             $vurl = $value[“videoUrl"];  
  59.             if (GlobalBase::is_ipad()) {  
  60.                 if($def==“hd"){  
  61.                     $videoinfo['code’] = 200;  
  62.                     $videoinfo[“data"][“url"] = $vurl;  
  63.                     break;  
  64.                 }  
  65.             }else{  
  66.                 if ($stream_type == 'mp5hd4’ && $m3u8 != ") {  
  67.                     $fdata[0]['url’] = $m3u8;  
  68.                     $fdata[0]['def’] = '4k’;  
  69.                 }   
  70.                 if ($stream_type == 'mp5hd3’ && $m3u8 != ") {  
  71.                     $fdata[1]['url’] = $m3u8;  
  72.                     $fdata[1]['def’] = 'mp5原画’;  
  73.                 }  
  74.                 $video[0] = $vurl;  
  75.                 $video[1] = “video/mp4";  
  76.                 $video[2] = $defname;  
  77.                 $video[3] =  $def ==“hd"? 10 : 0;  
  78.                 $videoinfo[“video"][$key] = $video;  
  79.             }  
  80.         }  
  81.         return $videoinfo;  
  82.     }  
  83.     public static function get_video_info($vid)  
  84.     {  
  85.         $api_video = “http://www.yinyuetai.com/insite/get-video-info?json=true&videoId={$vid}";  
  86.         $content = self::curl($api_video);  
  87.         //print_r($api_video);exit;  
  88.         $data = json_decode($content,true);  
  89.         $video_info = $data[“videoInfo"];  
  90.         $img = $video_info[“bigHeadImage"];  
  91.         $coreVideoInfo = $video_info[“coreVideoInfo"];  
  92.         $videoUrlModels = $coreVideoInfo[“videoUrlModels"];  
  93.         foreach ($videoUrlModels as $key => $value) {  
  94.             $def = $value[“qualityLevel"];  
  95.             $defname = $value[“qualityLevelName"];  
  96.             $vurl = $value[“videoUrl"];  
  97.             if (GlobalBase::is_ipad()) {  
  98.                 if($def==“hd"){  
  99.                     $videoinfo['code’] = 200;  
  100.                     $videoinfo['poster’] = $img;  
  101.                     $videoinfo['name’] = $video_info[“coreVideoInfo"][“videoName"];  
  102.                     $videoinfo['play’] = 'h5mp4’;  
  103.                     $videoinfo[“data"][“url"] = $vurl;  
  104.                     return $videoinfo;  
  105.                     exit;  
  106.                 }  
  107.             }else{  
  108.                 if ($def == 'sh’ && $vurl != ") {  
  109.                     $fdata[0]['url’] = $vurl;  
  110.                     $fdata[0]['def’] = '蓝光’;  
  111.                 }   
  112.                 if ($def == 'he’ && $vurl != ") {  
  113.                     $fdata[1]['url’] = $vurl;  
  114.                     $fdata[1]['def’] = '超清’;  
  115.                 }  
  116.                 if ($def == 'hd’ && $vurl != ") {  
  117.                     $fdata[2]['url’] = $vurl;  
  118.                     $fdata[2]['def’] = '高清’;  
  119.                 }   
  120.                 if ($def == 'hc’ && $vurl != ") {  
  121.                     $fdata[3]['url’] = $vurl;  
  122.                     $fdata[3]['def’] = '流畅’;  
  123.                 }  
  124.             }  
  125.         }  
  126.         for ($i=0; $i <= 10 ; $i++) {   
  127.             if ($fdata[$i] == ") {continue;}  
  128.             $key_arrays[]=$fdata[$i];  
  129.         }  
  130.         $videoinfo['code’] = 200;  
  131.         $videoinfo['poster’] = $img;  
  132.         $videoinfo['name’] = $video_info[“coreVideoInfo"][“videoName"];  
  133.         $videoinfo['play’] = 'h5mp4’;  
  134.         $videoinfo[“data"][“url"] = $key_arrays[0]['url’];  
  135.         return $videoinfo;  
  136.     }  
  137.     public static function curl($url)  
  138.     {  
  139.         $params[“ua"] = “Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.84 Safari/537.36";  
  140.         return GlobalBase::curl($url,$params);  
  141.     }  
  142. }  
  143.  ?>  

Posted by 柴郡猫