X-Git-Url: https://git.localhorst.tv/?a=blobdiff_plain;f=app%2FConsole%2FCommands%2FSyncZSR.php;fp=app%2FConsole%2FCommands%2FSyncZSR.php;h=65b21c187dbfaa4982bcce5105dec419939fb761;hb=ff8fc77e4fd1686bc1c1b34d094b11e6dfd93516;hp=1d9211025020e204b7f5dd5a725c800d1f0e578b;hpb=c96f2eb4ae81141c04241c673525569fef9cbaeb;p=alttp.git 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) {