|
|
发表于 2025-11-16 14:05:40
来自手机
|
显示全部楼层
zhujunrang 发表于 2025-11-16 08:32
怎么提取地址啊???
<?php
error_reporting(0);
$id = $_GET['id'] ?? 'bjws';
$n = [
'bjws' => '573ib1kp5nk92irinpumbo9krlb',
'bjwy' => '54db6gi5vfj8r8q1e6r89imd64s',
'bjjs' => '53bn9rlalq08lmb8nf8iadoph0b',
'bjys' => '50mqo8t4n4e8gtarqr3orj9l93v',
'bjcj' => '50e335k9dq488lb7jo44olp71f5',
'bjty' => '54hv0f3pq079d4oiil2k12dkvsc',
'bjsh' => '50j015rjrei9vmp3h8upblr41jf',
'bjxw' => '53gpt1ephlp86eor6ahtkg5b2hf',
'bjkk' => '55skfjq618b9kcq9tfjr5qllb7r',
];
// 播放列表生成
if (isset($_GET['action']) && $_GET['action'] === 'playlist') {
header('Content-Type: application/vnd.apple.mpegurl');
echo "#EXTM3U\n";
foreach ($n as $key => $value) {
$channelNames = [
'bjws' => '北京卫视',
'bjwy' => 'BRTV文艺',
'bjjs' => 'BRTV纪实科教',
'bjys' => 'BRTV影视',
'bjcj' => 'BRTV财经',
'bjty' => 'BRTV体育休闲',
'bjsh' => 'BRTV生活',
'bjxw' => 'BRTV新闻',
'bjkk' => '卡酷少儿',
];
echo "#EXTINF:-1, {$channelNames[$key]}\n";
echo "{$_SERVER['REQUEST_SCHEME']}://{$_SERVER['HTTP_HOST']}{$_SERVER['SCRIPT_NAME']}?id=$key\n";
}
exit;
}
// 检查频道是否存在
if (!isset($n[$id])) {
http_response_code(404);
header('Content-Type: text/plain; charset=utf-8');
die('错误:频道不存在');
}
try {
$t = time();
$sign = substr(md5($n[$id] . "151" . $t . 'TtJSg@2g*$K4PjUH'), 0, 8);
$url = "https://pc.api.btime.com/video/play?from=pc&id={$n[$id]}&type_id=151×tamp={$t}&sign={$sign}";
$ch = curl_init($url);
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_SSL_VERIFYPEER => 0,
CURLOPT_SSL_VERIFYHOST => 0,
CURLOPT_REFERER => 'https://www.brtn.cn/',
CURLOPT_TIMEOUT => 10,
]);
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if ($httpCode !== 200 || !$response) {
throw new Exception('API请求失败');
}
$data = json_decode($response, true);
if (!$data || !isset($data['data']['video_stream'][0]['stream_url'])) {
throw new Exception('解析流地址失败');
}
$stream_url = $data['data']['video_stream'][0]['stream_url'];
// **流地址
if ($id === 'bjws4k') {
$playurl = $stream_url;
} else {
$playurl = base64_decode(base64_decode(strrev($stream_url)));
}
// 重定向到最终播放地址
header("Location: " . $playurl);
} catch (Exception $e) {
http_response_code(500);
header('Content-Type: text/plain; charset=utf-8');
die('错误:' . $e->getMessage());
}
?> |
|