音悦台解析源码

作者 : King 本文共14个字,预计阅读时间需要1分钟 发布时间: 2024-10-4 共15人阅读

音悦台解析源码

音悦台解析源码

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

下载仅供下载体验和测试学习,不得商用和正当使用。

[ppwp passwords=”zhishitu.cn”]

下载体验

应版权要求,禁止分享,敬请谅解,有问题务必找客服哈。

如何获取解压密码

有问题找客服哈,并领取学习福利!

[/ppwp]

点击下载

小鱼网是一个美好的开源学习社区,学习编程,学习WordPress,下载WordPress插件主题,
小鱼网 » 音悦台解析源码

常见问题FAQ

发表回复

分享最优质的学习资料

立即查看 了解详情