Btjson博客 Btjson博客

音悦台解析源码(参考)

in 技术文章 read (312) 文章转载请注明来源!

只提供参考,自行测试更多资源交流群516722628

<?php 
echo json_encode(Yinyuetai::parse($url));
/**
* 
*/
class Yinyuetai
{

    /**
     * [parse 解析网页获取视频ID]
     * @param  [type] $url  [description]
     * @return [type]       [description]
     */
    public static function parse($url)
    {
        $html = self::curl($url);

        $vids = $aids = $titles = array();
        if ($html){
            preg_match('#id : "([\d]+)"#iU',$html,$vids);
            $vid = $vids[1];
            $data = self::get_video_info($vid);
            return $data;
        }
    }
    public static function get_video_urls($vid)
    {
        $api_video = "http://www.yinyuetai.com/api/info/get-video-urls?videoId={$vid}";
        $content = GlobalBase::curl($api_video);
        print_r($api_video);exit;
        $data = json_decode($content,true);
        $hd = $data["hdVideoUrl"];//高清
        $hc = $data["hcVideoUrl"];//流畅
        $he = $data["heVideoUrl"];//超清
        if (GlobalBase::is_ipad()) {
            $videoinfo["video"]["file"] = $hd;
            $videoinfo["video"]["type"] = "video/mp4";
        }else{
            $videoinfo["video"][0] = array($hd,"video/mp4","高清",10);
            $videoinfo["video"][1] = array($he,"video/mp4","超清",0);
            $videoinfo["video"][2] = array($hc,"video/mp4","流畅",0);
        }
        return $videoinfo;
    }
    public static function get_mv_info($vid)
    {
        $api_video = "http://ext.yinyuetai.com/main/get-h-mv-info?json=true&videoId={$vid}";
        $content = self::curl($api_video);
        print_r($content);exit;
        $data = json_decode($content,true);
        $video_info = $data["videoInfo"];
        $coreVideoInfo = $video_info["coreVideoInfo"];
        $img = $coreVideoInfo["bigHeadImage"];
        $videoUrlModels = $coreVideoInfo["videoUrlModels"];
        foreach ($videoUrlModels as $key => $value) {
            $def = $value["qualityLevel"];
            $defname = $value["qualityLevelName"];
            $vurl = $value["videoUrl"];
            if (GlobalBase::is_ipad()) {
                if($def=="hd"){
                    $videoinfo['code'] = 200;
                    $videoinfo["data"]["url"] = $vurl;
                    break;
                }
            }else{
                if ($stream_type == 'mp5hd4' && $m3u8 != '') {
                    $fdata[0]['url'] = $m3u8;
                    $fdata[0]['def'] = '4k';
                } 
                if ($stream_type == 'mp5hd3' && $m3u8 != '') {
                    $fdata[1]['url'] = $m3u8;
                    $fdata[1]['def'] = 'mp5原画';
                }
                $video[0] = $vurl;
                $video[1] = "video/mp4";
                $video[2] = $defname;
                $video[3] =  $def =="hd"? 10 : 0;
                $videoinfo["video"][$key] = $video;
            }
        }
        return $videoinfo;
    }
    public static function get_video_info($vid)
    {
        $api_video = "http://www.yinyuetai.com/insite/get-video-info?json=true&videoId={$vid}";
        $content = self::curl($api_video);
        //print_r($api_video);exit;
        $data = json_decode($content,true);
        $video_info = $data["videoInfo"];
        $img = $video_info["bigHeadImage"];
        $coreVideoInfo = $video_info["coreVideoInfo"];
        $videoUrlModels = $coreVideoInfo["videoUrlModels"];
        foreach ($videoUrlModels as $key => $value) {
            $def = $value["qualityLevel"];
            $defname = $value["qualityLevelName"];
            $vurl = $value["videoUrl"];
            if (GlobalBase::is_ipad()) {
                if($def=="hd"){
                    $videoinfo['code'] = 200;
                    $videoinfo['poster'] = $img;
                    $videoinfo['name'] = $video_info["coreVideoInfo"]["videoName"];
                    $videoinfo['play'] = 'h5mp4';
                    $videoinfo["data"]["url"] = $vurl;
                    return $videoinfo;
                    exit;
                }
            }else{
                if ($def == 'sh' && $vurl != '') {
                    $fdata[0]['url'] = $vurl;
                    $fdata[0]['def'] = '蓝光';
                } 
                if ($def == 'he' && $vurl != '') {
                    $fdata[1]['url'] = $vurl;
                    $fdata[1]['def'] = '超清';
                }
                if ($def == 'hd' && $vurl != '') {
                    $fdata[2]['url'] = $vurl;
                    $fdata[2]['def'] = '高清';
                } 
                if ($def == 'hc' && $vurl != '') {
                    $fdata[3]['url'] = $vurl;
                    $fdata[3]['def'] = '流畅';
                }
            }
        }
        for ($i=0; $i <= 10 ; $i++) { 
            if ($fdata[$i] == '') {continue;}
            $key_arrays[]=$fdata[$i];
        }
        $videoinfo['code'] = 200;
        $videoinfo['poster'] = $img;
        $videoinfo['name'] = $video_info["coreVideoInfo"]["videoName"];
        $videoinfo['play'] = 'h5mp4';
        $videoinfo["data"]["url"] = $key_arrays[0]['url'];
        return $videoinfo;
    }
    public static function curl($url)
    {
        $params["ua"] = "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.84 Safari/537.36";
        return GlobalBase::curl($url,$params);
    }
}
 ?>
jrotty WeChat Pay

微信打赏

jrotty Alipay

支付宝打赏

文章二维码

扫描二维码,在手机上阅读!

本文基于《署名-非商业性使用-相同方式共享 4.0 国际 (CC BY-NC-SA 4.0)》许可协议授权
文章链接:https://www.pohaier.com/2018/12/04/125.html (转载时请注明本文出处及文章链接)

技术文章
发表新评论
博客已萌萌哒运行
© 2019 由 Typecho 强力驱动.Theme by btjson
PREVIOUS NEXT
雷姆
拉姆