合肥电视台直播源变得很工整,但是播放不了。求大佬做个 php-iptv直播源、网络视频直播资源、直播代码-恩山无线论坛
header('Content-Type:text/json;charset=UTF-8');
$id = isset($_GET['id'])?$_GET['id']:'hfzh';
$n= [
'hfzh' => 10,//合肥新闻综合
'hfsh' => 13,//合肥生活
'hfcj' => 14,//合肥财*
'hfjy' => 15,//合肥教育法制
'hfxx' => 16,//合肥故事休闲
'hfgg' => 21,//合肥公共
];
$r = 'http://m.hfbtv.com/';
$h = ["User-Agent: Mozilla/5.0 (Windows NT 6.1)", "Referer: $r"];
if (empty($_GET['ts'])){
$url = "http://m.hfbtv.com/tvradio/Tvfront/getTvinfo?tv_id=".$n[$id];
$json = json_decode(getdata($url,$h,$r));
$m3u8 = $json -> data -> m3u8;
$bsurl = explode('playlist.m3u8',$m3u8)[0];
$m3u8 = str_replace("playlist","chunklist",$m3u8);
print_r(preg_replace("/(.*?.ts)/i",(isset($_SERVER["HTTPS"])&&$_SERVER["HTTPS"]==="on"?"https":"http")."://$_SERVER[HTTP_HOST]$_SERVER[PHP_SELF]?ts=$bsurl$1",getdata($m3u8,$h,$r)));
}
else{
$ts = getdata($_GET['ts'],$h,$r);
echo $ts;
}
function getdata($url,$header,$ref){
$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_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_REFERER, $ref);
$result = curl_exec($ch);
curl_close($ch);
return $result;
}
?>
评论列表
发表评论