2 * 1024 * 1024) { file_put_contents(LOG_FILE, "--- Log Cleared (Size Limit) ---\n"); } $time = date('Y-m-d H:i:s'); $content = is_array($msg) || is_object($msg) ? json_encode($msg, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) : $msg; file_put_contents(LOG_FILE, "[$time] $content\n", FILE_APPEND); } $ac = isset($_GET['ac']) ? $_GET['ac'] : ''; $t = isset($_GET['t']) ? $_GET['t'] : ''; $pg = isset($_GET['pg']) ? $_GET['pg'] : '1'; $wd = isset($_GET['wd']) ? $_GET['wd'] : ''; $ids = isset($_GET['ids']) ? $_GET['ids'] : ''; $play_url = isset($_GET['play_url']) ? $_GET['play_url'] : ''; $play = isset($_GET['play']) ? $_GET['play'] : ''; $current_script = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http") . "://$_SERVER[HTTP_HOST]$_SERVER[PHP_SELF]"; if ($ac == 'play' || !empty($play)) { if (empty($play_url) && !empty($play)) { $play_url = $play; } render_play($play_url); } elseif ($ac == 'detail' && !empty($ids)) { render_detail($ids, $current_script); } elseif (!empty($wd)) { render_search($wd, $pg); } elseif (!empty($t)) { render_category($t, $pg); } else { render_home(); } // ================= 业务逻辑 ================= function render_home() { $html = get_web_content(SITE_URL); $list = parse_video_list_robust($html); $data = [ "class" => [ ["type_id" => "tv", "type_name" => "剧集"], ["type_id" => "movies", "type_name" => "电影"], ["type_id" => "varietyshow", "type_name" => "综艺"], ["type_id" => "anime", "type_name" => "动漫"], ["type_id" => "shortdrama", "type_name" => "短剧"] ], "list" => $list, "filters" => new stdClass() ]; echo_json($data); } function render_category($tid, $pg) { $url = SITE_URL . '/' . $tid; if ($pg > 1) $url .= '/page/' . $pg; $html = get_web_content($url); $list = parse_video_list_robust($html); if (empty($list)) $list = []; echo_json([ "page" => intval($pg), "pagecount" => 999, "limit" => 20, "total" => 999, "list" => $list ]); } function render_search($wd, $pg) { $url = SITE_URL . '/search/video/w/' . urlencode($wd); if ($pg > 1) $url .= '/page/' . $pg; $html = get_web_content($url); $list = parse_search_results($html, $wd); echo_json([ "page" => intval($pg), "list" => $list ]); } function render_detail($ids, $script_url) { $url = SITE_URL . '/detail/' . $ids; $html = get_web_content($url); preg_match('/

(.*?)<\/h2>/', $html, $m_title); $title = $m_title[1] ?? '未知'; $pic = ''; if (preg_match('/class="detail-pic[^"]*".*?z-image-loader-url="(.*?)"/s', $html, $m_z)) { $pic = str_replace('`', '', $m_z[1]); } if (empty($pic) && preg_match('/class="detail-pic[^"]*".*?src="(.*?)"/s', $html, $m_p)) { $pic = $m_p[1]; } if (!empty($pic) && strpos($pic, 'http') === false) { if (strpos($pic, '//') === 0) $pic = 'https:' . $pic; else $pic = SITE_URL . $pic; } preg_match('/class="check desc-text selected">\s*(.*?)\s*<\/div>/s', $html, $m_desc); $desc = strip_tags($m_desc[1] ?? ''); $vod_play_from = []; $vod_play_url = []; preg_match_all('/