This commit is contained in:
make
2025-11-30 00:31:57 +08:00
parent 734527e8c7
commit 3cebb5b460
3 changed files with 17 additions and 85 deletions

View File

@@ -66,71 +66,29 @@ class VideoInfoPage extends BasePage
{
if (empty($this->arrVideo)) {
// $arrVideo = json_decode($this->getContent(), true);
// $arrVideo = $arrVideo['list'][0] ?? [];
// // 如果结构不正确 → 返回空数组
// if (!$arrVideo) {
// return [];
// }
// // 2. 检查播放地址
// $strPlayUrl = $arrVideo['vod_play_url'] ?? null;
// // 2. 判断是否有播放地址
// if (empty($arrVideo['vod_play_url'])) {
// // 无播放地址 → 丢弃该数据
// return [];
// }
// unset($arrVideo['vod_play_url']);
// $arrPlayUrl = str_replace('#', '$', $strPlayUrl);
// $arrPlayUrl = explode('$', $arrPlayUrl);
// $arrPlayUrl = array_filter($arrPlayUrl);
// $arrPlayUrl = array_chunk($arrPlayUrl, 2);
// foreach ($arrPlayUrl as $intKey => $arrVal) {
// $strUrl = $arrVal[1] ?? '';
// // *** 过滤掉不是 m3u8 的链接 ***
// if (!str_ends_with($strUrl, '.m3u8')) {
// continue;
// }
// $arrPlayUrl[$intKey] = [
// 'name' => $arrVal[0],
// 'url' => $strUrl,
// ];
// }
$arrVideo = json_decode($this->getContent(), true);
$arrVideo = $arrVideo['list'][0] ?? [];
// 如果结构不正确 → 返回空数组
if (!$arrVideo) {
return [];
}
// 2. 检查播放地址
$strPlayUrl = $arrVideo['vod_play_url'] ?? null;
// 2. 判断是否有播放地址
if (empty($arrVideo['vod_play_url'])) {
// 无播放地址 → 丢弃该数据
return [];
}
unset($arrVideo['vod_play_url']);
// 替换分隔符
$arrPlayUrl = str_replace('#', '$', $strPlayUrl);
// 拆成数组
$arrPlayUrl = explode('$', $arrPlayUrl);
// 清理空值
$arrPlayUrl = array_filter(array_map('trim', $arrPlayUrl));
// 转成二维数组:[[name,url], [name,url], ...]
$arrPlayUrl = array_chunk($arrPlayUrl, 2);
// 最终结构
$cleanPlayUrl = [];
foreach ($arrPlayUrl as $pair) {
$name = $pair[0] ?? '';
$url = $pair[1] ?? '';
// *** 过滤掉不是 m3u8 的链接 ***
if (!str_ends_with($url, '.m3u8')) {
continue;
}

View File

@@ -66,58 +66,29 @@ class VideoInfoPage extends BasePage
{
if (empty($this->arrVideo)) {
// $arrVideo = json_decode($this->getContent(), true);
// $arrVideo = $arrVideo['list'][0];
// // print_r($arrVideo);
// $strPlayUrl = $arrVideo['vod_play_url'];
// unset($arrVideo['vod_play_url']);
// $arrPlayUrl = str_replace('#', '$', $strPlayUrl);
// $arrPlayUrl = explode('$', $arrPlayUrl);
// $arrPlayUrl = array_filter($arrPlayUrl);
// $arrPlayUrl = array_chunk($arrPlayUrl, 2);
// foreach ($arrPlayUrl as $intKey => $arrVal) {
// $strUrl = $arrVal[1] ?? '';
// // *** 过滤掉不是 m3u8 的链接 ***
// if (!str_ends_with($strUrl, '.m3u8')) {
// continue;
// }
// $arrPlayUrl[$intKey] = [
// 'name' => $arrVal[0],
// 'url' => $strUrl,
// ];
// }
$arrVideo = json_decode($this->getContent(), true);
$arrVideo = $arrVideo['list'][0] ?? [];
// 如果结构不正确 → 返回空数组
if (!$arrVideo) {
return [];
}
// 2. 检查播放地址
$strPlayUrl = $arrVideo['vod_play_url'] ?? null;
// 2. 判断是否有播放地址
if (empty($arrVideo['vod_play_url'])) {
// 无播放地址 → 丢弃该数据
return [];
}
unset($arrVideo['vod_play_url']);
// 替换分隔符
$arrPlayUrl = str_replace('#', '$', $strPlayUrl);
// 拆成数组
$arrPlayUrl = explode('$', $arrPlayUrl);
// 清理空值
$arrPlayUrl = array_filter(array_map('trim', $arrPlayUrl));
// 转成二维数组:[[name,url], [name,url], ...]
$arrPlayUrl = array_chunk($arrPlayUrl, 2);
// 最终结构
$cleanPlayUrl = [];
foreach ($arrPlayUrl as $pair) {
$name = $pair[0] ?? '';
$url = $pair[1] ?? '';
// *** 过滤掉不是 m3u8 的链接 ***
if (!str_ends_with($url, '.m3u8')) {
continue;
}
@@ -128,8 +99,6 @@ class VideoInfoPage extends BasePage
}
$arrPlayUrl = $cleanPlayUrl;
$arrVideo['vod_actor'] = trim($arrVideo['vod_actor']);
$arrVideo['vod_director'] = trim($arrVideo['vod_director']);
$arrVideo['vod_class'] = trim($arrVideo['vod_class']);

View File

@@ -633,10 +633,15 @@ document.addEventListener("DOMContentLoaded", function () {
// 获取某个线路的第一个 url
function getFirstPlayUrl(playLine) {
return arrPlayUrl[playLine][0].url;
if (!arrPlayUrl || !arrPlayUrl[playLine] || !arrPlayUrl[playLine][0]) {
console.warn("播放线路不存在:", playLine, arrPlayUrl);
return null;
}
return arrPlayUrl[playLine][0].url || null;
}
})