PHP环境提取m3u8,PHP读取转发M3U8的方法 PHP解码转发M3U8

M3U8的原理我这里就不再累赘了,我们可以用PHP的CURL方法模拟访客获取到M3U8,然后继续往下解码出TS文件,然后传给DB,CK之类播放器播放

一份源码如下:

笨牛网原创的噢

header("ACCESS-CONTROL-ALLOW-ORIGIN:*");

$action = $_GET['action'];

function getcurl($url){

$user_agent = "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0)";

$ch = curl_init();

//curl_setopt ($ch, CURLOPT_PROXY, $proxy);

curl_setopt ($ch, CURLOPT_URL, $url);//设置要访问的IP

curl_setopt ($ch, CURLOPT_USERAGENT, $user_agent);//模拟用户使用的浏览器

curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1 ); // 使用自动跳转

curl_setopt ($ch, CURLOPT_TIMEOUT, 60); //设置超时时间

curl_setopt ($ch, CURLOPT_AUTOREFERER, 1 ); // 自动设置Referer

//curl_setopt ($ch, CURLOPT_COOKIEJAR, 'c:\cookie.txt');

curl_setopt ($ch, CURLOPT_HEADER,0); //显示返回的HEAD区域的内容

curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);

curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1);

curl_setopt ($ch, CURLOPT_TIMEOUT, 30);

$result = curl_exec($ch);

curl_close($ch);

return $result;

}

if(!$action){

$url='https://new.jsyunbf.com/20180727/QwSTlb89/index.m3u8';

$m3u8 =getcurl($url);

preg_match_all('#/[^\s]*#i', $m3u8, $match);

echo preg_replace('#/[^\s]*#i','https://test2.bnxb.com/get.php?action=https://new.jsyunbf.com$0',$m3u8);

}

else{

$url2= $action;

$m3u8 =getcurl($url2);

//print_r($m3u8);

echo preg_replace('#/[^\s]*#i','https://new.jsyunbf.com$0',$m3u8);

}

?>

播放方法,就是找个播放器

然后https://www.bnxb.com/dplayer.html?url=https://test2.bnxb.com/get.php

类似方法

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值