Btjson博客 Btjson博客

一直播解析源码(参考)

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

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

<?php 
//require_once("../include/global.inc.php");
//$url = "http://www.yizhibo.com/l/v-InULNRQCjyrNSv.html";
echo json_encode(YiZhiBo::parse($url));
/**
* 
*/
class YiZhiBo
{

    public static function parse($url)
    {
        $content = self::curl($url);
        preg_match('#play_url:"(.*)",#',$content,$urls);
        preg_match('#scid:"(.*)",#',$content,$vids);
        preg_match('#covers:"(.*)",#',$content,$posters);
        preg_match('#nickname:"(.*)",#',$content,$names);

        $ids['vid'] = isset($vids[1]) ? $vids[1] : exit('dd');
        $ids['url'] = isset($urls[1]) ? $urls[1] : '';
        $ids['poster'] = isset($posters[1]) ? $posters[1] : '';
        $ids['name'] = isset($names[1]) ? $names[1] : '';
        return self::get_video_info($ids);
    }
    public static function get_video_info($ids)
    {
        $api = "http://www.yizhibo.com/live/h5api/get_basic_live_info?scid={$ids['vid']}";
        $content = self::curl($api);
        $json = json_decode($content,true);
        if(isset($json["data"])){
            $data = $json["data"];
            $name = isset($data["nickname"]) ? $data["nickname"] : $ids['name'];
            $videoinfo['code'] = 200;
            $videoinfo["data"]["poster"] = isset($data["covers"]) ? $data["covers"] : $ids['poster'];
            $videoinfo["data"]["url"] = isset($data["play_url"]) ? $data["play_url"] : $ids['url'];
            $videoinfo["data"]["name"] = $name;
            $videoinfo["play"] = 'hls';
        }
        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/142.html (转载时请注明本文出处及文章链接)

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