From 8908aa7a8245f08244c6046c29dced782b2572a9 Mon Sep 17 00:00:00 2001 From: advplyr Date: Sat, 28 Jan 2023 14:58:10 -0600 Subject: [PATCH] Fix:Podcast RSS feeds update on new/updated episodes #1435 --- server/managers/RssFeedManager.js | 12 ++++++++++-- server/objects/Feed.js | 12 ++++++++---- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/server/managers/RssFeedManager.js b/server/managers/RssFeedManager.js index 5b103d2f..1d842559 100644 --- a/server/managers/RssFeedManager.js +++ b/server/managers/RssFeedManager.js @@ -81,9 +81,17 @@ class RssFeedManager { } // Check if feed needs to be updated - if (feed.entityType === 'item') { + if (feed.entityType === 'libraryItem') { const libraryItem = this.db.getLibraryItem(feed.entityId) - if (libraryItem && (!feed.entityUpdatedAt || libraryItem.updatedAt > feed.entityUpdatedAt)) { + + let mostRecentlyUpdatedAt = libraryItem.updatedAt + if (libraryItem.isPodcast) { + libraryItem.media.episodes.forEach((episode) => { + if (episode.updatedAt > mostRecentlyUpdatedAt) mostRecentlyUpdatedAt = episode.updatedAt + }) + } + + if (libraryItem && (!feed.entityUpdatedAt || mostRecentlyUpdatedAt > feed.entityUpdatedAt)) { Logger.debug(`[RssFeedManager] Updating RSS feed for item ${libraryItem.id} "${libraryItem.media.metadata.title}"`) feed.updateFromItem(libraryItem) await this.db.updateEntity('feed', feed) diff --git a/server/objects/Feed.js b/server/objects/Feed.js index 307a842c..cc5e804f 100644 --- a/server/objects/Feed.js +++ b/server/objects/Feed.js @@ -110,13 +110,15 @@ class Feed { this.episodes = [] if (isPodcast) { // PODCAST EPISODES media.episodes.forEach((episode) => { - var feedEpisode = new FeedEpisode() + if (episode.updatedAt > this.entityUpdatedAt) this.entityUpdatedAt = episode.updatedAt + + const feedEpisode = new FeedEpisode() feedEpisode.setFromPodcastEpisode(libraryItem, serverAddress, slug, episode, this.meta) this.episodes.push(feedEpisode) }) } else { // AUDIOBOOK EPISODES media.tracks.forEach((audioTrack) => { - var feedEpisode = new FeedEpisode() + const feedEpisode = new FeedEpisode() feedEpisode.setFromAudiobookTrack(libraryItem, serverAddress, slug, audioTrack, this.meta) this.episodes.push(feedEpisode) }) @@ -144,13 +146,15 @@ class Feed { this.episodes = [] if (isPodcast) { // PODCAST EPISODES media.episodes.forEach((episode) => { - var feedEpisode = new FeedEpisode() + if (episode.updatedAt > this.entityUpdatedAt) this.entityUpdatedAt = episode.updatedAt + + const feedEpisode = new FeedEpisode() feedEpisode.setFromPodcastEpisode(libraryItem, this.serverAddress, this.slug, episode, this.meta) this.episodes.push(feedEpisode) }) } else { // AUDIOBOOK EPISODES media.tracks.forEach((audioTrack) => { - var feedEpisode = new FeedEpisode() + const feedEpisode = new FeedEpisode() feedEpisode.setFromAudiobookTrack(libraryItem, this.serverAddress, this.slug, audioTrack, this.meta) this.episodes.push(feedEpisode) })