求助 铜川电视台
网址:https://www.tcrbs.com/tvradio/tczhpd.html网页中的url不可以使用感觉又是 调用了这个 player 的函数,,,求教这个函数中的 HlsPlayer 是什么? 如何使用php 搞一下
player函数 在 https://template.tcrbs.com/xgplayer3/play.js
function player(videoUrl,poster,autoplay,isLive){
const config = {
"id": "mse",
"url": videoUrl,
"playsinline": true,
"poster": poster,
"plugins": [],
"isLive": isLive,
"autoplay": autoplay,
"pip": true,
"fluid": true,
"playbackRate": [
1
],
"volume": 0.6,
"height": "520"
};
if(videoUrl.indexOf(".m3u8") > -1){
config.plugins.push(HlsPlayer)
}
let player = new Player(config);
} 流年爱看剧 发表于 2024-3-25 21:24
需要切片了,加了referer zhanghu4366 发表于 2024-3-25 21:45
需要切片了,加了referer
:'(. 还没有学会这个。有出来一个 referer。 气死了 <?php
error_reporting(0);
$ts = $_GET['ts'];
$header_4=["Referer: https://www.tcrbs.com/"];//传递头文件
if(!$ts){
$id = $_GET['id']?$_GET['id']:'zh';
$n = [
"zh" => "zh",//新闻综合
"gg" => "gg",//公共频道
];
$url = "https://www.tcrbs.com/tvradio/tc{$n[$id]}pd.html";
$api_data = curl_get($url, array('SSL'=>1,'ADD_HEADER_ARRAY'=>$header_4));
preg_match("/videoUrl = '(.*?)';/i",$api_data,$m3u8);
$playurl = $m3u8['1'];
$burl = dirname($playurl)."/";
$host = "http://".$_SERVER ['HTTP_HOST'].$_SERVER['PHP_SELF']; //如果你网站协议头是https,将http换成https;
$playurl_data = curl_get($playurl, array('SSL'=>1,'ADD_HEADER_ARRAY'=>$header_4));
header('Content-Type: application/vnd.apple.mpegurl');
header("Content-Disposition: attachment; filename=index.m3u8");
print_r(preg_replace("/(.*?.ts)/i", $host."?ts=$burl$1",$playurl_data));
} else {
$data = curl_get($ts, array('SSL'=>1,'ADD_HEADER_ARRAY'=>$header_4));
header('Content-Type: video/MP2T');
header("Content-Disposition: attachment; filename=".time().".ts");
print_r($data);die;
}
function curl_get($url, $array=array()){
$defaultOptions = array(
'IPHONE_UA'=>1,
'SSL'=>0,
'TOU'=>0,
'ADD_HEADER_ARRAY'=>0,
'POST'=>0,
'REFERER'=>0,
'USERAGENT'=>0,
'CURLOPT_FOLLOWLOCATION'=>0
);
$array = array_merge($defaultOptions, $array);
$ch = curl_init($url);
if($array['SSL']){
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
}
if ($array['IPHONE_UA'])
{
curl_setopt($ch, CURLOPT_HTTPHEADER, array('User-Agent: Mozilla/5.0 (iPhone; U; CPU iPhone OS 3_1_2 like Mac OS X; en-us) AppleWebKit/528.18 (KHTML, like Gecko) Version/4.0 Mobile/7D11 Safari/528.16'));
}
if (is_array($array['ADD_HEADER_ARRAY']))
{
curl_setopt($ch, CURLOPT_HTTPHEADER, $array['ADD_HEADER_ARRAY']);
}
if ($array['POST'])
{
curl_setopt($ch, CURLOPT_POSTFIELDS, $array['POST']);
}
if ($array['REFERER'])
{
curl_setopt($ch, CURLOPT_REFERER, $array['REFERER']);
}
if ($array['USERAGENT'])
{
curl_setopt($ch, CURLOPT_USERAGENT, $array['USERAGENT']);
}
if($array['TOU']){
curl_setopt($ch, CURLOPT_HEADER, 1); //输出响应头
}
if ($array['CURLOPT_FOLLOWLOCATION'])
{
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);//自动跟踪跳转的链接
}
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$get_url = curl_exec($ch);
curl_close($ch);
return $get_url;
}
?>试下 可以使用。太感谢了。大佬 这代码 可以 举一反三吧 可以使用。太感谢了。大佬 这代码 可以 举一反三吧 zhanghu4366 发表于 2024-3-25 21:53
试下
可以使用。太感谢了。大佬 这代码 可以 举一反三吧 改协议头:https =》http 本帖最后由 guoma 于 2024-3-26 00:54 编辑
zhanghu4366 发表于 2024-3-25 21:53
试下
搞得复杂!!!简单点:
<?php
error_reporting(0);
$ts = $_GET['ts'];
if(!$ts){
$id = $_GET['id']?$_GET['id']:'tczh';
$n = [
"tczh" => "zh",//新闻综合
"tcgg" => "gg",//公共频道
];
$data = get("https://www.tcrbs.com/tvradio/tc{$n[$id]}pd.html");
preg_match("/videoUrl = '(.*?)'/",$data,$p);
$live = $p;
$burl = dirname($live)."/";
$php = "http://".$_SERVER ['HTTP_HOST'].$_SERVER['PHP_SELF'];//如果你网站协议头是https,将http换成https;
$playurl = get($live);
header('Content-Type: application/vnd.apple.mpegurl');
print_r(preg_replace("/(.*?.ts)/i", $php."?ts=$burl$1",$playurl));
} else {
$data = get($ts);
header('Content-Type: video/MP2T');
print_r($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://www.tcrbs.com/');
$d = curl_exec($ch);
curl_close($ch);
return $d;
}
?>
铜川综合,http://:6060/yinhe/2/ch00000090990000001735/index.m3u8?virtualDomain=yinhe.live_hls.zte.com#
铜川公共,http://:6060/yinhe/2/ch00000090990000001770/index.m3u8?virtualDomain=yinhe.live_hls.zte.com# wuhen70 发表于 2024-3-26 22:01
铜川综合,http://:6060/yinhe/2/ch00000090990000001735/index.m3u8?virtualD ...
谢谢谢谢谢谢谢谢谢谢
页:
[1]