yf1197565391 发表于 2024-8-28 21:29:37

兰州php请教

帖子没了,guama这个看不了,之前改成啥了,帖子没了,请大战神赐教,谢谢!


<?php
error_reporting(0);
$id = $_GET["id"]??'10';//9 10 11 12 13
$info = file_get_contents("http://mapi.lztv.tv/api/open/lztv/channel_detail.php?appid=m2oaflekvvackack70&appkey=9f20111f111d6a1afc56809d98c373f0&channel_id={$id}");
$m3u8 = json_decode($info)->m3u8;
$burl = dirname($m3u8).'/';
$live = $burl.strstr(getdata($m3u8),'HD');
$php = "http://".$_SERVER ['HTTP_HOST'].$_SERVER['PHP_SELF'];

if($id==9||$id==13){
   $ts = $_GET['ts'];
   if(!$ts) {
      print_r(preg_replace("/(.*?.ts)/i", $php."?ts=$burl$1", getdata(trim($live))));
      } else {
      $data = getdata($ts);
      print_r($data);
      }
   }

if($id==10||$id==11||$id==12){
   $aac = $_GET['aac'];
   if(!$aac) {
   $burl1 = "https://liveplus.lztv.tv";
   $p = preg_replace("/(.*?.aac)/i", "$burl1$1", getdata(trim($live)));
   print_r(str_replace("https",$php."?aac=https",preg_replace("/https:\/\/liveplus.lztv.tv_/","_",$p)));
   } else {
       $data = getdata($aac);
       print_r($data);
       }
   }

function getdata($url){
       $ch = curl_init($url);
       curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
       curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
       curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
       curl_setopt($ch, CURLOPT_REFERER, 'https://www.lztv.tv/');
       $res = curl_exec($ch);
       curl_close($ch);
       return $res;
       }
?>

guoma 发表于 2024-8-28 21:45:57

<?php
error_reporting(0);
$id = isset($_GET['id'])?$_GET['id']:'lzxwzh';
$ts = $_GET['ts'];
$n = [
   'lzxwzh' => ['xwzh','tv'],//新闻综合
   'lzwl' => ['wlpd','tv'],//文旅
   'lzzhgb' => ['aac_zhgb','gb'], //兰州新闻综合广播
   'lzyygb' => ['aac_jtyy','gb'], //兰州音乐广播
   'lzwygb' => ['aac_shwy','gb'], //兰州文艺广播
   ];
$m3u8 = "https://liveplus.lztv.tv/{$n[$id]}/HD/live.m3u8";
$php = (isset($_SERVER['HTTPS'])&& $_SERVER['HTTPS']==='on'?"https":"http")."://".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'];
$burl = "https://liveplus.lztv.tv";

if($n[$id]=="tv"){
   if(!$ts) {
   header('Content-Type: application/vnd.apple.mpegurl');
   print_r(preg_replace("/(.*?.ts)/i", $php."?ts=$burl$1",get($m3u8)));
   } else {
       $data = get($ts);
       header('Content-Type: video/MP2T');
       echo $data;
       }
}

if($n[$id]=="gb"){
    if(!$ts) {
       $a = preg_replace("/aac_/", "aab_", get($m3u8));
       $b =preg_replace("/(.*?.aac)/i", $php."?ts=$burl$1", $a);
       header('Content-Type: application/vnd.apple.mpegurl');
       print_r(preg_replace("/aab_/", "aac_", $b));
       } else {
         $d = get($ts);
         header('Content-Type: video/MP2T');
         echo $d;
         }
}
function get($url){
       $ch = curl_init($url);
       curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
       curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
       curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
       curl_setopt($ch, CURLOPT_REFERER, 'https://www.lztv.tv/');
       $res = curl_exec($ch);
       curl_close($ch);
       return $res;
       }
?>

657374416@qq.co 发表于 2024-8-29 09:52:39

来学习下{:4_112:}
页: [1]
查看完整版本: 兰州php请教