|
|
发表于 2025-10-27 14:54:49
|
显示全部楼层
<?php
error_reporting(0);
header('Content-Type: text/plain; charset=utf-8');
$n = [
'cdtv1' => 1,
'cdtv2' => 2,
'cdtv3' => 3,
'cdtv4' => 45,
'cdtv5' => 5,
'cdtv6' => 6,
'cdrcxf' => 15,
];
$m = [
'chyx' => 1319,
'cztv' => 1257,
'djytv' => 1314,
'dytv' => 790,
'gxtv' => 722,
'jjtv' => 1541,
'jntv' => 556,
'jttv' => 840,
'jyxwzh' => 1698,
'lqzh' => 882,
'pdxwzh' => 845,
'pjtv' => 828,
'pztv' => 796,
'qbjtv' => 966,
'qltv' => 1427,
'qytv' => 910,
'slzh' => 557,
'whtv' => 1766,
'wjtv' => 559,
'xdtv' => 1712,
'xjtv' => 760,
];
$id = isset($_GET['id']) ? $_GET['id'] : 'cdtv1';
$t = isset($_GET['t']) ? $_GET['t'] : 'hd'; // hd or sd
$url = null;
if (isset($n[$id])) {
$url = "http://mob.api.cditv.cn/show/192-{$n[$id]}.html";
} elseif (isset($m[$id])) {
$url = "http://mob.api.cditv.cn/show/192-{$m[$id]}.html";
} else {
die("Invalid channel ID: $id");
}
$context = stream_context_create(['http' => ['timeout' => 5]]);
$content = @file_get_contents($url, false, $context);
if (!$content) {
die("Failed to fetch data from API.");
}
$json = json_decode($content);
if (!$json || !isset($json->data)) {
die("Invalid JSON response from API.");
}
if (isset($n[$id])) {
$m3u8_sd = isset($json->data->android_url) ? preg_replace('/^http:/i', 'https:', $json->data->android_url) : '';
$m3u8_hd = isset($json->data->android_HDlive_url) ? preg_replace('/^http:/i', 'https:', $json->data->android_HDlive_url) : '';
if (!$m3u8_sd && !$m3u8_hd) {
die("No stream URL available for this channel.");
}
$target = ($t === 'hd' && $m3u8_hd) ? $m3u8_hd : $m3u8_sd;
header('Location: ' . $target);
exit();
} elseif (isset($m[$id])) {
$m3u8 = $json->data->android_url ?? '';
if (empty($m3u8)) {
die("No stream URL available for this county channel.");
}
header('Location: ' . $m3u8);
exit();
}
?> |
|