diff --git a/client/components/cards/LazyBookCard.vue b/client/components/cards/LazyBookCard.vue index a08caf55..be101e82 100644 --- a/client/components/cards/LazyBookCard.vue +++ b/client/components/cards/LazyBookCard.vue @@ -672,20 +672,25 @@ export default { if (fullLibraryItem && fullLibraryItem.media.episodes) { const episodes = fullLibraryItem.media.episodes || [] - episodes.sort((a, b) => b.publishedAt - a.publishedAt) + // Sort from least recent to most recent + episodes.sort((a, b) => String(a.publishedAt).localeCompare(String(b.publishedAt), undefined, { numeric: true, sensitivity: 'base' })) + const episodeIndex = episodes.findIndex((ep) => ep.id === this.recentEpisode.id) if (episodeIndex >= 0) { for (let i = episodeIndex; i < episodes.length; i++) { const episode = episodes[i] - const audioFile = episode.audioFile - queueItems.push({ - libraryItemId: this.libraryItemId, - episodeId: episode.id, - title: episode.title, - subtitle: this.mediaMetadata.title, - duration: audioFile.duration || null, - coverPath: this.media.coverPath || null - }) + const podcastProgress = this.store.getters['user/getUserMediaProgress'](this.libraryItemId, episode.id) + if (!podcastProgress || !podcastProgress.isFinished) { + queueItems.push({ + libraryItemId: this.libraryItemId, + episodeId: episode.id, + title: episode.title, + subtitle: this.mediaMetadata.title, + caption: episode.publishedAt ? `Published ${this.$formatDate(episode.publishedAt, 'MMM do, yyyy')}` : 'Unknown publish date', + duration: episode.audioFile.duration || null, + coverPath: this.media.coverPath || null + }) + } } } } diff --git a/client/components/modals/player/QueueItemRow.vue b/client/components/modals/player/QueueItemRow.vue index aa710df7..f9378dc7 100644 --- a/client/components/modals/player/QueueItemRow.vue +++ b/client/components/modals/player/QueueItemRow.vue @@ -3,7 +3,8 @@

{{ title }}

-

{{ subtitle }}

+

{{ subtitle }}

+

{{ caption }}

Streaming

@@ -41,6 +42,9 @@ export default { subtitle() { return this.item.subtitle || '' }, + caption() { + return this.item.caption + }, libraryItemId() { return this.item.libraryItemId }, diff --git a/client/components/tables/podcast/EpisodesTable.vue b/client/components/tables/podcast/EpisodesTable.vue index 20864cdd..ac5e4c67 100644 --- a/client/components/tables/podcast/EpisodesTable.vue +++ b/client/components/tables/podcast/EpisodesTable.vue @@ -128,18 +128,23 @@ export default { }, playEpisode(episode) { const queueItems = [] - const episodeIndex = this.episodes.findIndex((e) => e.id === episode.id) - for (let i = episodeIndex; i < this.episodes.length; i++) { - const episode = this.episodes[i] - const audioFile = episode.audioFile - queueItems.push({ - libraryItemId: this.libraryItem.id, - episodeId: episode.id, - title: episode.title, - subtitle: this.mediaMetadata.title, - duration: audioFile.duration || null, - coverPath: this.media.coverPath || null - }) + + const episodesInListeningOrder = this.episodesCopy.map((ep) => ({ ...ep })).sort((a, b) => String(a.publishedAt).localeCompare(String(b.publishedAt), undefined, { numeric: true, sensitivity: 'base' })) + const episodeIndex = episodesInListeningOrder.findIndex((e) => e.id === episode.id) + for (let i = episodeIndex; i < episodesInListeningOrder.length; i++) { + const episode = episodesInListeningOrder[i] + const podcastProgress = this.$store.getters['user/getUserMediaProgress'](this.libraryItem.id, episode.id) + if (!podcastProgress || !podcastProgress.isFinished) { + queueItems.push({ + libraryItemId: this.libraryItem.id, + episodeId: episode.id, + title: episode.title, + subtitle: this.mediaMetadata.title, + caption: episode.publishedAt ? `Published ${this.$formatDate(episode.publishedAt, 'MMM do, yyyy')}` : 'Unknown publish date', + duration: episode.audioFile.duration || null, + coverPath: this.media.coverPath || null + }) + } } this.$eventBus.$emit('play-item', { diff --git a/client/pages/item/_id/index.vue b/client/pages/item/_id/index.vue index 03c52696..ff2cbcbd 100644 --- a/client/pages/item/_id/index.vue +++ b/client/pages/item/_id/index.vue @@ -519,25 +519,31 @@ export default { var episodeId = null const queueItems = [] if (this.isPodcast) { - var episodeIndex = this.podcastEpisodes.findIndex((ep) => { + const episodesInListeningOrder = this.podcastEpisodes.map((ep) => ({ ...ep })).sort((a, b) => String(a.publishedAt).localeCompare(String(b.publishedAt), undefined, { numeric: true, sensitivity: 'base' })) + + // Find most recent episode unplayed + var episodeIndex = episodesInListeningOrder.findLastIndex((ep) => { var podcastProgress = this.$store.getters['user/getUserMediaProgress'](this.libraryItemId, ep.id) return !podcastProgress || !podcastProgress.isFinished }) if (episodeIndex < 0) episodeIndex = 0 - episodeId = this.podcastEpisodes[episodeIndex].id + episodeId = episodesInListeningOrder[episodeIndex].id - for (let i = episodeIndex; i < this.podcastEpisodes.length; i++) { - const episode = this.podcastEpisodes[i] - const audioFile = episode.audioFile - queueItems.push({ - libraryItemId: this.libraryItemId, - episodeId: episode.id, - title: episode.title, - subtitle: this.title, - duration: audioFile.duration || null, - coverPath: this.libraryItem.media.coverPath || null - }) + for (let i = episodeIndex; i < episodesInListeningOrder.length; i++) { + const episode = episodesInListeningOrder[i] + const podcastProgress = this.$store.getters['user/getUserMediaProgress'](this.libraryItemId, episode.id) + if (!podcastProgress || !podcastProgress.isFinished) { + queueItems.push({ + libraryItemId: this.libraryItemId, + episodeId: episode.id, + title: episode.title, + subtitle: this.title, + caption: episode.publishedAt ? `Published ${this.$formatDate(episode.publishedAt, 'MMM do, yyyy')}` : 'Unknown publish date', + duration: episode.audioFile.duration || null, + coverPath: this.libraryItem.media.coverPath || null + }) + } } }