fix: preserve live streams on title edits

This commit is contained in:
hajimi
2026-06-21 13:44:05 +08:00
parent 08c1affb14
commit 75a529be35
6 changed files with 140 additions and 22 deletions
@@ -49,21 +49,28 @@ class MatchLiveLogic extends BaseLogic
$oldMatchId = (int) $live->match_id;
$newMatchId = (int) $params['match_id'];
$now = time();
$sourceUrl = trim((string) $params['source_url']);
$sourceUrlChanged = $sourceUrl !== trim((string) $live->source_url);
$live->save([
$saveData = [
'match_id' => $newMatchId,
'title' => trim((string) $params['title']),
'source_url' => trim((string) $params['source_url']),
'play_url_m3u8' => '',
'play_url_hd_m3u8' => '',
'play_url_flv' => '',
'play_url_hd_flv' => '',
'fetch_status' => 0,
'fetch_error' => '',
'last_fetch_at' => 0,
'next_fetch_at' => $now,
'source_url' => $sourceUrl,
'update_time' => $now,
]);
];
if ($sourceUrlChanged) {
$saveData['play_url_m3u8'] = '';
$saveData['play_url_hd_m3u8'] = '';
$saveData['play_url_flv'] = '';
$saveData['play_url_hd_flv'] = '';
$saveData['fetch_status'] = 0;
$saveData['fetch_error'] = '';
$saveData['last_fetch_at'] = 0;
$saveData['next_fetch_at'] = $now;
}
$live->save($saveData);
if ($oldMatchId > 0 && $oldMatchId !== $newMatchId) {
MatchLiveService::syncLegacyLiveUrl($oldMatchId);