2024年2月18日更新 非凡和量子 修复了一下。
<?php
/*
* @author NodeLoc
* @contact 208524822
* @date 2024年2月18日
* 非凡资源站:ffzy.tv
* 量子资源站:lzzy.tv
* 暴风资源站:bfzy.tv
* 极光资源站:jiguang.la
*/
//关闭所有PHP错误报告
error_reporting(0);
//是否缓存视频链接 1 缓存 0 不缓存
define('IFHC', 1);
//缓存保存的文件夹 如果不缓存请无视
if (strstr($_GET['url'], '.ffzy')) {
$mulu = "/feifan/";
}//非凡缓存目录
if (strstr($_GET['url'], '.cdnlz')) {
$mulu = "/liangzi/";
}//量子缓存目录
if (strstr($_GET['url'], '.bfzy')) {
$mulu = "/baofeng/";
}//暴风缓存目录
if (strstr($_GET['url'], '.jiguang')) {
$mulu = "/jiguang/";
}//极光缓存目录
if ($mulu == '') {
$mulu = "/m3u8/";
}//其他缓存目录
define('HCFILE', __DIR__ . $mulu);
//缓存时效 秒为单位 如果不缓存请无视
define('HCTIME', 604800);
//设置编码
header('Content-type: text/json;charset=utf-8');
//开始
$url = $_GET["url"];
$url = str_replace('http://', 'https://', $url);
$DATA = curl($url);
preg_match('/RESOLUTION=(.*)\n?(.*)/', $DATA, $jmurl);
$url = str_replace('index.m3u8', $jmurl[2], $url);
if (strstr($url, ".ffzy") == true) {
$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()) {
$http_type = ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') || (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https')) ? 'https://' : 'http://';
if (strstr($_GET['url'], '.ffzy')) {
$mulu = "/feifan/";
}//非凡缓存目录
if ($mulu == '') {
$mulu = "/m3u8/";
}//其他缓存目录
$t1 = microtime(true);
$t2 = microtime(true);
$arr = array(
'code' => 200,
'msg' => '解析成功',
// 'cache' => true,
'url' => $http_type . $_SERVER['HTTP_HOST'] . $mulu . $MD5,
);
die(json_encode($arr, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
}
$data = curl($url);
if (empty($data)) {
die(404);
}
//判断是否为.m3u8
if (strstr($url, ".m3u8") == true) {
echo m3u8ts($url, $MD5, $data, $explode[2]);
}
}
if (strstr($url, ".cdnlz") == true) {
$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()) {
$http_type = ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') || (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https')) ? 'https://' : 'http://';
if (strstr($_GET['url'], '.cdnlz')) {
$mulu = "/liangzi/";
}//量子缓存目录
if ($mulu == '') {
$mulu = "/m3u8/";
}//其他缓存目录
$arr = array(
'code' => 200,
'msg' => '解析成功',
// 'cache' => true,
'url' => $http_type . $_SERVER['HTTP_HOST'] . $mulu . $MD5,
);
die(json_encode($arr, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
}
$data = curl($url);
if (empty($data)) {
die(404);
}
//判断是否为.m3u8
if (strstr($url, ".m3u8") == true) {
echo m3u8ts($url, $MD5, $data, $explode[2]);
}
}
if (strstr($_GET["url"], ".bfzy") == true) {
$MD5 = Md5($_GET["url"]) . '.m3u8';
if (is_dir(HCFILE) == false) {
mkdir(HCFILE, 0755, true);
}
if (IFHC == 1 && file_exists(HCFILE . $MD5) && filemtime(HCFILE . $MD5) + HCTIME > time()) {
$http_type = ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') || (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https')) ? 'https://' : 'http://';
if (strstr($_GET['url'], '.bfzy')) {
$mulu = "/baofeng/";
}//暴风缓存目录
if ($mulu == '') {
$mulu = "/m3u8/";
}//其他缓存目录
$arr = array(
'code' => 200,
'msg' => '解析成功',
// 'cache' => true,
'url' => $http_type . $_SERVER['HTTP_HOST'] . $mulu . $MD5,
);
die(json_encode($arr, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
}
$data = curl($_GET["url"]);
if (empty($data)) {
die(404);
}
//判断是否为.m3u8
if (strstr($_GET["url"], ".m3u8") == true) {
echo m3u8ts($_GET["url"], $MD5, $data, $explode[2]);
}
}
if (strstr($_GET["url"], ".jiguang") == true) {
$MD5 = Md5($_GET["url"]) . '.m3u8';
if (is_dir(HCFILE) == false) {
mkdir(HCFILE, 0755, true);
}
if (IFHC == 1 && file_exists(HCFILE . $MD5) && filemtime(HCFILE . $MD5) + HCTIME > time()) {
$http_type = ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') || (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https')) ? 'https://' : 'http://';
if (strstr($_GET['url'], '.jiguang')) {
$mulu = "/jiguang/";
}//极光缓存目录
if ($mulu == '') {
$mulu = "/m3u8/";
}//其他缓存目录
$arr = array(
'code' => 200,
'msg' => '解析成功',
// 'cache' => true,
'url' => $http_type . $_SERVER['HTTP_HOST'] . $mulu . $MD5,
);
die(json_encode($arr, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
}
$data = curl($_GET["url"]);
if (empty($data)) {
die(404);
}
//判断是否为.m3u8
if (strstr($_GET["url"], ".m3u8") == true) {
echo m3u8ts($_GET["url"], $MD5, $data, $explode[2]);
}
}
if ($decrypted == false) {
$add['code'] = 404;
$add["msg"] = '解析失败';
}
echo json_encode($add, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
function m3u8ts($wz, $file, $data, $name)
{
$data = preg_replace('/#EXT-X-DISCONTINUITY\n?/', "", $data);
$data = preg_replace('/1o(\d{0,9}).ts/', "", $data);
if (strstr($_GET["url"], ".bfzy") == true) {
$data = preg_replace('/(\d+){12}(\d{0,9}).ts/', "", $data);
}
if (strstr($_GET["url"], ".ffzy") == true) {
$data = preg_replace('/(\d+){12}(\d{0,9}).ts/', "", $data);
}
if (strstr($_GET["url"], ".jiguang") == true) {
$data = preg_replace('/(\d+){10}.ts/', "", $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);
$lines = explode(PHP_EOL, $m3u8);
$last_order = -1;
foreach ($lines as $line) {
if (strpos($line, 'http') !== false) {
preg_match('/(\d+)\.ts/', $line, $matches);
$order = intval($matches[1]);
if ($order > $last_order) {
$filtered_lines[] = $line;
$last_order = $order;
}
} else {
$filtered_lines[] = $line;
}
}
$filtered_lines_hc = implode(PHP_EOL, $filtered_lines);
$filtered_lines_hc = preg_replace('/#EXTINF:6.433333,\n?#EXTINF:(.*),\n?#EXTINF:(.*),\n?#EXTINF:(.*),\n?#EXTINF:(.*),\n?/', "", $filtered_lines_hc);
$filtered_lines_hc = preg_replace('/#EXTINF:6.666667,\n?#EXTINF:(.*),\n?#EXTINF:(.*),\n?#EXTINF:(.*),\n?/', "", $filtered_lines_hc);
$filtered_lines_hc = preg_replace('/#EXTINF:3,\n?#EXTINF:(.*),\n?#EXTINF:(.*),\n?#EXTINF:(.*),\n?/', "", $filtered_lines_hc);
$filtered_lines_hc = preg_replace('/#EXTINF:2.000000,\n?#EXTINF:(.*),\n?#EXTINF:(.*),\n?#EXTINF:(.*),\n?\n?#EXTINF:(.*),\n?/', "", $filtered_lines_hc);
// file_put_contents(HCFILE.$file, implode(PHP_EOL, $filtered_lines));
file_put_contents(HCFILE . $file, $filtered_lines_hc);
$http_type = ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') || (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https')) ? 'https://' : 'http://';
if (strstr($_GET['url'], '.ffzy')) {
$mulu = "/feifan/";
}//非凡缓存目录
if (strstr($_GET['url'], '.cdnlz')) {
$mulu = "/liangzi/";
}//量子缓存目录
if (strstr($_GET['url'], '.bfzy')) {
$mulu = "/baofeng/";
}//暴风缓存目录
if (strstr($_GET['url'], '.jiguang')) {
$mulu = "/jiguang/";
}//极光缓存目录
if ($mulu == '') {
$mulu = "/m3u8/";
}//其他缓存目录
$arr = array(
'code' => 200,
'msg' => '解析成功',
'url' => $http_type . $_SERVER['HTTP_HOST'] . $mulu . $file,
);
die(json_encode($arr, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
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",
"Accept: application/json, text/javascript, */*; q=0.01",
"X-FORWARDED-FOR:" . rand_ip(),
"CLIENT-IP:" . rand_ip(),
"X-Real-IP:" . rand_ip(),
"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, '');
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;
}
function rand_ip()
{
$ip_long = array(
array('607649792', '608174079'), //36.56.0.0-36.63.255.255
array('975044608', '977272831'), //58.30.0.0-58.63.255.255
array('999751680', '999784447'), //59.151.0.0-59.151.127.255
array('1019346944', '1019478015'), //60.194.0.0-60.195.255.255
array('1038614528', '1039007743'), //61.232.0.0-61.237.255.255
array('1783627776', '1784676351'), //106.80.0.0-106.95.255.255
array('1947009024', '1947074559'), //116.13.0.0-116.13.255.255
array('1987051520', '1988034559'), //118.112.0.0-118.126.255.255
array('2035023872', '2035154943'), //121.76.0.0-121.77.255.255
array('2078801920', '2079064063'), //123.232.0.0-123.235.255.255
array('-1950089216', '-1948778497'), //139.196.0.0-139.215.255.255
array('-1425539072', '-1425014785'), //171.8.0.0-171.15.255.255
array('-1236271104', '-1235419137'), //182.80.0.0-182.92.255.255
array('-770113536', '-768606209'), //210.25.0.0-210.47.255.255
array('-569376768', '-564133889'), //222.16.0.0-222.95.255.255
);
$rand_key = mt_rand(0, 14);
$huoduan_ip = long2ip(mt_rand($ip_long[$rand_key][0], $ip_long[$rand_key][1]));
return $huoduan_ip;
}