NOW直播解析源码

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

NOW直播解析源码

NOW直播解析源码

  1. //https://now.qq.com/cgi-bin/now/web/room/get_room_info_v2?room_id=1983753
  2. //https://now.qq.com/cgi-bin/now/web/user/get_personal_live_rcmd_read?_=0.6791041731369902&bkn=869715713&num=19&tab_id=2
  3. //https://now.qq.com/pc/index.html?roomid=1210251521
  4. //https://now.qq.com/h5/index.html?roomid=79072731
  5. //https://now.qq.com/cgi-bin/now/web/room/get_live_room_url?platform=4&room_id=1210676514
  6. //require_once(“../include/global.inc.php”);
  7. echo json_encode(Now::parse($url));
  8. /**
  9. */
  10. class Now
  11. {
  12.     public static function parse($url)
  13.     {
  14.         parse_str(parse_url($url)[“query”]);
  15.         if($roomid){
  16.             return self::get_room_info_v2($roomid);
  17.         }
  18.     }
  19.     public static function get_room_info_v2($room_id)
  20.     {
  21.         $api = “https://now.qq.com/cgi-bin/now/web/room/get_room_info_v2?room_id=$room_id”;
  22.         $content = self::curl($api);
  23.         $data = json_decode($content,true)[“result”];
  24.         $is_on_live = $data[“is_on_live”];
  25.         if($is_on_live){//是否直播
  26.             return self::get_live_room_url($room_id);
  27.         }else{
  28.             if(!emptyempty($data[“vid”])){
  29.                 $vid = $data[“vid”];
  30.                 return self::get_record_room_info($vid);
  31.             }else{
  32.                 return GlobalBase::get_unknown_video();
  33.             }
  34.         }
  35.     }
  36.     public static function get_record_room_info($vid)
  37.     {
  38.         $api = “https://now.qq.com/cgi-bin/now/web/room/get_record_room_info?vid=$vid”;
  39.         $content = self::curl($api);
  40.         $data = json_decode($content,true)[“result”];
  41.         $record_video_url = $data[“record_video_url”];
  42.         $video_cover_url = $data[“video_cover_url”];
  43.         $videoinfo[“poster”] = $video_cover_url;
  44.         $videoinfo[“video”][“file”] = $record_video_url;
  45.         $videoinfo[“video”][“type”] = “video/m3u8″;
  46.         return $videoinfo;
  47.     }
  48.     public static function get_live_room_url($room_id)
  49.     {
  50.         $api = “https://now.qq.com/cgi-bin/now/web/room/get_live_room_url?platform=4&room_id=$room_id”;
  51.         $content = self::curl($api);
  52.         $data = json_decode($content,true)[“result”];
  53.         $videoURLList = $data[“videoURLList”];
  54.         foreach ($videoURLList as $key => $value) {
  55.             if (GlobalBase::is_ipad()) {
  56.                 $videoinfo[“url”]= $value;
  57.                 break;
  58.             }else{
  59.                 switch ($key) {
  60.                     case 0:$def = “自动”;break;
  61.                     case 1:$def = “高清”;break;
  62.                     case 2:$def = “标清”;break;
  63.                     case 3:$def = “流畅”;break;
  64.                 }
  65.                 $videoinfo[“live”] = true;
  66.                 $video[0] = $value;
  67.                 $video[1] = “video/m3u8″;
  68.                 $video[2] = $def;
  69.                 $video[3] =  $key != 0 ? 0 : 10;
  70.                 $videoinfo[“video”][$key] = $video;
  71.             }
  72.         }
  73.         return $videoinfo;
  74.     }
  75.     public static function curl($url)
  76.     {
  77.         $params[“ua”] = “Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.84 Safari/537.36″;
  78.         return GlobalBase::curl($url,$params);
  79.     }
  80. }
  81.  ?>

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

[ppwp passwords=”zhishitu.cn”]

下载体验

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

如何获取解压密码

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

[/ppwp]

点击下载

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

常见问题FAQ

发表回复

分享最优质的学习资料

立即查看 了解详情