mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-02-06 05:20:11 +01:00
Update podcast episode queue order
This commit is contained in:
parent
d11501b2c6
commit
872d5178e6
@ -672,24 +672,29 @@ export default {
|
|||||||
|
|
||||||
if (fullLibraryItem && fullLibraryItem.media.episodes) {
|
if (fullLibraryItem && fullLibraryItem.media.episodes) {
|
||||||
const episodes = 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)
|
const episodeIndex = episodes.findIndex((ep) => ep.id === this.recentEpisode.id)
|
||||||
if (episodeIndex >= 0) {
|
if (episodeIndex >= 0) {
|
||||||
for (let i = episodeIndex; i < episodes.length; i++) {
|
for (let i = episodeIndex; i < episodes.length; i++) {
|
||||||
const episode = episodes[i]
|
const episode = episodes[i]
|
||||||
const audioFile = episode.audioFile
|
const podcastProgress = this.store.getters['user/getUserMediaProgress'](this.libraryItemId, episode.id)
|
||||||
|
if (!podcastProgress || !podcastProgress.isFinished) {
|
||||||
queueItems.push({
|
queueItems.push({
|
||||||
libraryItemId: this.libraryItemId,
|
libraryItemId: this.libraryItemId,
|
||||||
episodeId: episode.id,
|
episodeId: episode.id,
|
||||||
title: episode.title,
|
title: episode.title,
|
||||||
subtitle: this.mediaMetadata.title,
|
subtitle: this.mediaMetadata.title,
|
||||||
duration: audioFile.duration || null,
|
caption: episode.publishedAt ? `Published ${this.$formatDate(episode.publishedAt, 'MMM do, yyyy')}` : 'Unknown publish date',
|
||||||
|
duration: episode.audioFile.duration || null,
|
||||||
coverPath: this.media.coverPath || null
|
coverPath: this.media.coverPath || null
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
eventBus.$emit('play-item', {
|
eventBus.$emit('play-item', {
|
||||||
libraryItemId: this.libraryItemId,
|
libraryItemId: this.libraryItemId,
|
||||||
|
@ -3,7 +3,8 @@
|
|||||||
<covers-preview-cover :src="coverUrl" :width="48" :book-cover-aspect-ratio="bookCoverAspectRatio" :show-resolution="false" />
|
<covers-preview-cover :src="coverUrl" :width="48" :book-cover-aspect-ratio="bookCoverAspectRatio" :show-resolution="false" />
|
||||||
<div class="flex-grow px-2 py-1 queue-item-row-content truncate">
|
<div class="flex-grow px-2 py-1 queue-item-row-content truncate">
|
||||||
<p class="text-gray-200 text-sm truncate">{{ title }}</p>
|
<p class="text-gray-200 text-sm truncate">{{ title }}</p>
|
||||||
<p class="text-gray-400 text-sm">{{ subtitle }}</p>
|
<p class="text-gray-300 text-sm">{{ subtitle }}</p>
|
||||||
|
<p v-if="caption" class="text-gray-400 text-xs">{{ caption }}</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="w-28">
|
<div class="w-28">
|
||||||
<p v-if="isOpenInPlayer" class="text-sm text-right text-gray-400">Streaming</p>
|
<p v-if="isOpenInPlayer" class="text-sm text-right text-gray-400">Streaming</p>
|
||||||
@ -41,6 +42,9 @@ export default {
|
|||||||
subtitle() {
|
subtitle() {
|
||||||
return this.item.subtitle || ''
|
return this.item.subtitle || ''
|
||||||
},
|
},
|
||||||
|
caption() {
|
||||||
|
return this.item.caption
|
||||||
|
},
|
||||||
libraryItemId() {
|
libraryItemId() {
|
||||||
return this.item.libraryItemId
|
return this.item.libraryItemId
|
||||||
},
|
},
|
||||||
|
@ -128,19 +128,24 @@ export default {
|
|||||||
},
|
},
|
||||||
playEpisode(episode) {
|
playEpisode(episode) {
|
||||||
const queueItems = []
|
const queueItems = []
|
||||||
const episodeIndex = this.episodes.findIndex((e) => e.id === episode.id)
|
|
||||||
for (let i = episodeIndex; i < this.episodes.length; i++) {
|
const episodesInListeningOrder = this.episodesCopy.map((ep) => ({ ...ep })).sort((a, b) => String(a.publishedAt).localeCompare(String(b.publishedAt), undefined, { numeric: true, sensitivity: 'base' }))
|
||||||
const episode = this.episodes[i]
|
const episodeIndex = episodesInListeningOrder.findIndex((e) => e.id === episode.id)
|
||||||
const audioFile = episode.audioFile
|
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({
|
queueItems.push({
|
||||||
libraryItemId: this.libraryItem.id,
|
libraryItemId: this.libraryItem.id,
|
||||||
episodeId: episode.id,
|
episodeId: episode.id,
|
||||||
title: episode.title,
|
title: episode.title,
|
||||||
subtitle: this.mediaMetadata.title,
|
subtitle: this.mediaMetadata.title,
|
||||||
duration: audioFile.duration || null,
|
caption: episode.publishedAt ? `Published ${this.$formatDate(episode.publishedAt, 'MMM do, yyyy')}` : 'Unknown publish date',
|
||||||
|
duration: episode.audioFile.duration || null,
|
||||||
coverPath: this.media.coverPath || null
|
coverPath: this.media.coverPath || null
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
this.$eventBus.$emit('play-item', {
|
this.$eventBus.$emit('play-item', {
|
||||||
libraryItemId: this.libraryItem.id,
|
libraryItemId: this.libraryItem.id,
|
||||||
|
@ -519,27 +519,33 @@ export default {
|
|||||||
var episodeId = null
|
var episodeId = null
|
||||||
const queueItems = []
|
const queueItems = []
|
||||||
if (this.isPodcast) {
|
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)
|
var podcastProgress = this.$store.getters['user/getUserMediaProgress'](this.libraryItemId, ep.id)
|
||||||
return !podcastProgress || !podcastProgress.isFinished
|
return !podcastProgress || !podcastProgress.isFinished
|
||||||
})
|
})
|
||||||
if (episodeIndex < 0) episodeIndex = 0
|
if (episodeIndex < 0) episodeIndex = 0
|
||||||
|
|
||||||
episodeId = this.podcastEpisodes[episodeIndex].id
|
episodeId = episodesInListeningOrder[episodeIndex].id
|
||||||
|
|
||||||
for (let i = episodeIndex; i < this.podcastEpisodes.length; i++) {
|
for (let i = episodeIndex; i < episodesInListeningOrder.length; i++) {
|
||||||
const episode = this.podcastEpisodes[i]
|
const episode = episodesInListeningOrder[i]
|
||||||
const audioFile = episode.audioFile
|
const podcastProgress = this.$store.getters['user/getUserMediaProgress'](this.libraryItemId, episode.id)
|
||||||
|
if (!podcastProgress || !podcastProgress.isFinished) {
|
||||||
queueItems.push({
|
queueItems.push({
|
||||||
libraryItemId: this.libraryItemId,
|
libraryItemId: this.libraryItemId,
|
||||||
episodeId: episode.id,
|
episodeId: episode.id,
|
||||||
title: episode.title,
|
title: episode.title,
|
||||||
subtitle: this.title,
|
subtitle: this.title,
|
||||||
duration: audioFile.duration || null,
|
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
|
coverPath: this.libraryItem.media.coverPath || null
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
this.$eventBus.$emit('play-item', {
|
this.$eventBus.$emit('play-item', {
|
||||||
libraryItemId: this.libraryItem.id,
|
libraryItemId: this.libraryItem.id,
|
||||||
|
Loading…
Reference in New Issue
Block a user