From: Daniel Karbach Date: Tue, 21 May 2024 09:18:38 +0000 (+0200) Subject: fix zsr sync X-Git-Url: https://git.localhorst.tv/?a=commitdiff_plain;h=ff8fc77e4fd1686bc1c1b34d094b11e6dfd93516;p=alttp.git fix zsr sync --- diff --git a/app/Console/Commands/SyncZSR.php b/app/Console/Commands/SyncZSR.php index 1d92110..65b21c1 100644 --- a/app/Console/Commands/SyncZSR.php +++ b/app/Console/Commands/SyncZSR.php @@ -88,17 +88,6 @@ class SyncZSR extends Command { } else { $episode->title = $entry['summary']; } - if (preg_match('/Restream: https?:\/\/(www\.)?twitch\.tv\/(\w+)/u', $entry['description'], $matches)) { - $channel = $this->syncChannel($episode, $matches[2]); - if ($channel) { - $episode->channels()->syncWithoutDetaching([$channel->id]); - } - } - if (preg_match('/^(.*) - (.*?) vs (.*?)$/u', $episode->title, $matches)) { - $episode->title = $matches[1]; - $this->syncPlayer($episode, $matches[2]); - $this->syncPlayer($episode, $matches[3]); - } $start = Carbon::parse($entry['start']['dateTime'])->setTimezone('UTC'); if (!$episode->start || $start->ne($episode->start)) { $episode->start = $start; @@ -106,7 +95,20 @@ class SyncZSR extends Command { $end = Carbon::parse($entry['end']['dateTime'])->setTimezone('UTC'); $episode->estimate = $start->diffInSeconds($end); $episode->confirmed = true; - $episode->save(); + if (preg_match('/^(.*) - (.*?) vs\.? (.*?)$/u', $episode->title, $matches)) { + $episode->title = $matches[1]; + $episode->save(); + $this->syncPlayer($episode, $matches[2]); + $this->syncPlayer($episode, $matches[3]); + } else { + $episode->save(); + } + if (preg_match('/Restream: https?:\/\/(www\.)?twitch\.tv\/(\w+)/u', $entry['description'], $matches)) { + $channel = $this->syncChannel($episode, $matches[2]); + if ($channel) { + $episode->channels()->syncWithoutDetaching([$channel->id]); + } + } } private function syncChannel(Episode $episode, $zsrChannel) {