<?php
error_reporting(0);
//关闭所有PHP错误报告
define('IFHC',1);
//是否缓存视频链接 1 缓存 0 不缓存
define('HCFILE',__DIR__.'/cache/');
//缓存保存的文件夹 如果不缓存请无视
define('HCTIME',604800);
//缓存时效 秒为单位 如果不缓存请无视
header('Content-type: text/json;charset=utf-8');
$url = $_GET['url'];
$MD5 = Md5($url).'.m3u8';
if (is_dir(HCFILE)==false) {
mkdir(HCFILE,0755,true);
}
if (IFHC==1 && file_exists(HCFILE.$MD5) && filemtime(HCFILE.$MD5) + HCTIME > time()) {
$arr = array(
'code' => 200,
'msg' => '解析成功',
'cache' => true,
'url' => 'https://www.wucuoym.com/cache/'.$MD5
);
die(json_encode($arr,456));
}
$data = curl($url);
if (empty($data)) {
die(404);
}
if (strstr($data,'.ts')==false) {
$explode = explode('/',$data);
$ts = explode("\n",$explode[0])[2];
$url = str_replace('index.m3u8','', $url).$ts.'/'.$explode[1].'/'.$explode[2];
$data = curl($url);
if (empty($data)) {
die(404);
}
}
echo m3u8ts($url,$MD5,$data,$explode[2]);
function m3u8ts($wz , $file , $data , $name){
$data = preg_replace('/#EXTINF:(.*),\n?http(.*)\n?/','',$data);
preg_match('/\/\/(.*)\/'.$name.'/',$wz,$ym);
$web = 'https:'.str_replace($name,'', $ym[0]);
$m3u8 = preg_replace('/#EXTINF:(.*),\n?(.*)\n?/',"#EXTINF:$1,\n$web$2\n",$data);
file_put_contents(HCFILE.$file,$m3u8);
$arr = array(
'code' => 200,
'msg' => '解析成功',
'url' => 'https://www.wucuoym.com/cache/'.$file
);
die(json_encode($arr,456));
return;
}
function curl($url) {
if(!function_exists('curl_init')) die('php.ini未开启php_curl.dll');
$user_agent = $_SERVER['HTTP_USER_AGENT'];
$ch = curl_init();
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
"accept: */*",
"accept-encoding: gzip, deflate",
"accept-language: zh-CN,zh;q=0.9",
"Connection: keep-alive",
));
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.99 Safari/537.36');
curl_setopt($ch, CURLOPT_REFERER,'https://www.wucuoym.com/');
curl_setopt($ch, CURLOPT_ENCODING, "gzip, deflate");
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
@ $file = curl_exec($ch);
curl_close($ch);
return $file;
}
PHP无错源码所有资源来自会员发布以及互联网收集,不代表本站立场,如有侵犯你的权益请联系管理员,站内发信联系 我们会第一时间进行审核删除。站内资源为网友个人学习或测试研究使用,未经原版权作者许可,禁止用于任何商业途径!本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。请在下载24小时内删除!
如果遇到付费才可观看的文章,建议升级传奇VIP。全站所有资源“任意下免费看”。本站资源少部分采用7z压缩,为防止有人压缩软件不支持7z格式,7z解压,建议下载7-zip,zip、rar解压,建议下载WinRAR。如遇解压需要密码,请尝试使用www.wucuoym.com来解压,如若仍有问题,请联系站长。