如何再切片?请教下各位大佬
<?php$targetUrl = 'https://mapi.hoolo.tv/api/v1/channel_detail.php?channel_id=16';
$fakeReferer = 'https://tv.hoolo.tv/';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $targetUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_REFERER, $fakeReferer);
$response = curl_exec($ch);
if (curl_errno($ch)) {
echo 'Curl error: '. curl_error($ch);
}
curl_close($ch);
$pattern = '/"m3u8":\s*"([^"]+)"/';
preg_match($pattern, $response, $matches);
$m3u8Value = str_replace('\\', '', $matches);
echo$m3u8Value;
?>
本帖最后由 guoma 于 2025-3-15 11:32 编辑
<?php
error_reporting(0);
$id = $_GET['id'] ?? 'hzzh';
$n = [
'hzzh' => 16, //杭州综合
'hzmz' => 17, //西湖明珠
'hzsh' => 18, //杭州生活
'hzys' => 21, //杭州影视
'hzqsty' => 20, //青少体育
'hzds' => 22, //杭州导视
'fyxwzh' => 32, //富阳新闻综合
];
$url = 'https://mapi.hoolo.tv/api/v1/channel_detail.php?channel_id='.$n[$id];
if($id=='fyxwzh'){
$live = json_decode(get($url),1)['channel_stream']['m3u8'];
} else {
$live = json_decode(get($url),1)['channel_stream']['m3u8'];
};
$host = parse_url($live)['host'];
$php = "http://".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'];
$burl = "https://{$host}";
$ts = $_GET['ts'];
if(empty($ts)) {
$p = get($live);
header('Content-Type: application/vnd.apple.mpegurl');
print_r(preg_replace("/(.*?.ts)/i", $php."?ts=$burl$1",$p));
} else {
$data = get($ts);
header('Content-Type: video/MP2T');
echo $data;
}
function get($url){
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_REFERER, 'https://tv.hoolo.tv/');
$res = curl_exec($ch);
curl_close($ch);
return $res;
}
?> 大佬就是厉害! guoma 发表于 2025-3-13 23:27
想问下大佬,如果ts的时间是非固定的,还能实现切片代理吗 人生没有彩排,每天都是直播。 大佬就是厉害! 人生没有彩排,每天都是直播 还是大佬厉害啊··
页:
[1]