fix: syncing podcasts

This commit is contained in:
Phan An 2024-07-08 23:15:19 +02:00
parent 4dbffdb734
commit 92b90f7859

View file

@ -91,6 +91,17 @@ class PodcastService
$parser = $this->createParser($podcast->url);
$channel = $parser->getChannel();
$pubDate = $parser->xmlReader->value('rss.channel.pubDate')->first()
?? $parser->xmlReader->value('rss.channel.lastBuildDate')->first();
if ($pubDate && Carbon::createFromFormat(Carbon::RFC1123, $pubDate)->isBefore($podcast->last_synced_at)) {
// The pubDate/lastBuildDate value indicates that there's no new content since last check.
// We'll simply return the podcast.
return $podcast;
}
$this->synchronizeEpisodes($podcast, $parser->getEpisodes(true));
$podcast->update([
'title' => $channel->title,
'description' => $channel->description,
@ -104,17 +115,6 @@ class PodcastService
'last_synced_at' => now(),
]);
$pubDate = $parser->xmlReader->value('rss.channel.pubDate')->first()
?? $parser->xmlReader->value('rss.channel.lastBuildDate')->first();
if ($pubDate && Carbon::createFromFormat(Carbon::RFC1123, $pubDate)->isBefore($podcast->last_synced_at)) {
// The pubDate/lastBuildDate value indicates that there's no new content since last check.
// We'll simply return the podcast.
return $podcast;
}
$this->synchronizeEpisodes($podcast, $parser->getEpisodes(true));
return $podcast->refresh();
}