deploy: auto commit repo-root changes 2026-06-21 17:56:21
This commit is contained in:
@@ -23,20 +23,38 @@ class MatchLiveService
|
||||
|
||||
public static function getLiveListForApi(int $matchId): array
|
||||
{
|
||||
$rows = MatchLive::where('match_id', $matchId)
|
||||
$liveMap = self::getLiveMapForApi([$matchId]);
|
||||
|
||||
return $liveMap[$matchId] ?? [];
|
||||
}
|
||||
|
||||
public static function getLiveMapForApi(array $matchIds): array
|
||||
{
|
||||
$matchIds = array_values(array_unique(array_filter(array_map('intval', $matchIds))));
|
||||
if (empty($matchIds)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$rows = MatchLive::whereIn('match_id', $matchIds)
|
||||
->whereNull('delete_time')
|
||||
->order('create_time', 'asc')
|
||||
->order('id', 'asc')
|
||||
->select()
|
||||
->toArray();
|
||||
|
||||
$result = [];
|
||||
foreach ($rows as &$row) {
|
||||
$row['stream_options'] = self::buildStreamOptions($row);
|
||||
$row['default_play_url'] = $row['stream_options'][0]['url'] ?? '';
|
||||
$row['default_play_url'] = self::resolveDefaultPlayUrl($row);
|
||||
$matchId = (int) ($row['match_id'] ?? 0);
|
||||
if ($matchId <= 0) {
|
||||
continue;
|
||||
}
|
||||
$result[$matchId][] = $row;
|
||||
}
|
||||
unset($row);
|
||||
|
||||
return $rows;
|
||||
return $result;
|
||||
}
|
||||
|
||||
public static function buildStreamOptions(array $row): array
|
||||
@@ -62,4 +80,20 @@ class MatchLiveService
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
protected static function resolveDefaultPlayUrl(array $row): string
|
||||
{
|
||||
if (!empty($row['stream_options'][0]['url'])) {
|
||||
return trim((string) $row['stream_options'][0]['url']);
|
||||
}
|
||||
|
||||
foreach (['play_url_m3u8', 'play_url_hd_m3u8', 'play_url_flv', 'play_url_hd_flv'] as $field) {
|
||||
$url = trim((string) ($row[$field] ?? ''));
|
||||
if ($url !== '') {
|
||||
return $url;
|
||||
}
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user