From f2d0d0cba8818ac75c911b264201b0d2a91a0195 Mon Sep 17 00:00:00 2001 From: Phan An Date: Sat, 5 Oct 2024 13:59:10 +0200 Subject: [PATCH] chore: several improvements for PodcastService (#1836) --- app/Services/PodcastService.php | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/app/Services/PodcastService.php b/app/Services/PodcastService.php index 6c1b7cee..240bd6b8 100644 --- a/app/Services/PodcastService.php +++ b/app/Services/PodcastService.php @@ -148,7 +148,7 @@ class PodcastService // We use insert() instead of $podcast->episodes()->createMany() for better performance, // as the latter would trigger a separate query for each episode. - Episode::insert($records); + Episode::query()->insert($records); // Since insert() doesn't trigger model events, Scout operations will not be called. // We have to manually update the search index. @@ -190,7 +190,7 @@ class PodcastService } try { - $lastModified = Http::send('HEAD', $podcast->url)->header('Last-Modified'); + $lastModified = Http::head($podcast->url)->header('Last-Modified'); return $lastModified && Carbon::createFromFormat(Carbon::RFC1123, $lastModified)->isAfter($podcast->last_synced_at); @@ -204,10 +204,7 @@ class PodcastService */ public function getStreamableUrl(string|Episode $url, ?Client $client = null, string $method = 'OPTIONS'): ?string { - if (!is_string($url)) { - $url = $url->path; - } - + $url = $url instanceof Episode ? $url->path : $url; $client ??= new Client(); try {