61 lines
1.7 KiB
PHP
61 lines
1.7 KiB
PHP
<?php
|
|
|
|
$root = dirname(__DIR__, 2);
|
|
$servicePath = $root . '/server/app/common/service/match/MatchLiveService.php';
|
|
|
|
if (!is_file($servicePath)) {
|
|
fwrite(STDERR, "missing service file\n");
|
|
exit(1);
|
|
}
|
|
|
|
$service = file_get_contents($servicePath);
|
|
$requiredSnippets = [
|
|
'class MatchLiveService',
|
|
'public static function syncLegacyLiveUrl',
|
|
'public static function getLiveListForApi',
|
|
'public static function buildStreamOptions',
|
|
"'live_url' => \$row ? (string) \$row->source_url : ''",
|
|
"'update_time' => time()",
|
|
"->whereNull('delete_time')",
|
|
"->order('create_time', 'asc')",
|
|
"->order('id', 'asc')",
|
|
"\$row['default_play_url'] = \$row['stream_options'][0]['url'] ?? '';",
|
|
"if (\$url === '')",
|
|
];
|
|
|
|
foreach ($requiredSnippets as $needle) {
|
|
if (strpos($service, $needle) === false) {
|
|
fwrite(STDERR, "missing service token: {$needle}\n");
|
|
exit(1);
|
|
}
|
|
}
|
|
|
|
$whereNullCount = substr_count($service, "->whereNull('delete_time')");
|
|
if ($whereNullCount < 2) {
|
|
fwrite(STDERR, "missing explicit delete_time guard on both queries\n");
|
|
exit(1);
|
|
}
|
|
|
|
$orderedOptionSnippets = [
|
|
"['label' => 'M3U8', 'field' => 'play_url_m3u8']",
|
|
"['label' => 'HD M3U8', 'field' => 'play_url_hd_m3u8']",
|
|
"['label' => 'FLV', 'field' => 'play_url_flv']",
|
|
"['label' => 'HD FLV', 'field' => 'play_url_hd_flv']",
|
|
];
|
|
|
|
$lastPos = -1;
|
|
foreach ($orderedOptionSnippets as $snippet) {
|
|
$pos = strpos($service, $snippet);
|
|
if ($pos === false) {
|
|
fwrite(STDERR, "missing ordered stream option snippet: {$snippet}\n");
|
|
exit(1);
|
|
}
|
|
if ($pos <= $lastPos) {
|
|
fwrite(STDERR, "stream option order mismatch\n");
|
|
exit(1);
|
|
}
|
|
$lastPos = $pos;
|
|
}
|
|
|
|
echo "service static checks passed\n";
|