mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-08-04 02:05:06 +02:00
Update PlaybackSession to use new library item model
This commit is contained in:
parent
d205c6f734
commit
c251f1899d
16 changed files with 284 additions and 193 deletions
|
@ -276,6 +276,78 @@ class Podcast extends Model {
|
|||
return hasUpdates
|
||||
}
|
||||
|
||||
checkCanDirectPlay(supportedMimeTypes, episodeId) {
|
||||
if (!Array.isArray(supportedMimeTypes)) {
|
||||
Logger.error(`[Podcast] checkCanDirectPlay: supportedMimeTypes is not an array`, supportedMimeTypes)
|
||||
return false
|
||||
}
|
||||
const episode = this.podcastEpisodes.find((ep) => ep.id === episodeId)
|
||||
if (!episode) {
|
||||
Logger.error(`[Podcast] checkCanDirectPlay: episode not found`, episodeId)
|
||||
return false
|
||||
}
|
||||
return supportedMimeTypes.includes(episode.audioFile.mimeType)
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the track list to be used in client audio players
|
||||
* AudioTrack is the AudioFile with startOffset and contentUrl
|
||||
* Podcast episodes only have one track
|
||||
*
|
||||
* @param {string} libraryItemId
|
||||
* @param {string} episodeId
|
||||
* @returns {import('./Book').AudioTrack[]}
|
||||
*/
|
||||
getTracklist(libraryItemId, episodeId) {
|
||||
const episode = this.podcastEpisodes.find((ep) => ep.id === episodeId)
|
||||
if (!episode) {
|
||||
Logger.error(`[Podcast] getTracklist: episode not found`, episodeId)
|
||||
return []
|
||||
}
|
||||
|
||||
const audioTrack = episode.getAudioTrack(libraryItemId)
|
||||
return [audioTrack]
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {string} episodeId
|
||||
* @returns {import('./PodcastEpisode').ChapterObject[]}
|
||||
*/
|
||||
getChapters(episodeId) {
|
||||
const episode = this.podcastEpisodes.find((ep) => ep.id === episodeId)
|
||||
if (!episode) {
|
||||
Logger.error(`[Podcast] getChapters: episode not found`, episodeId)
|
||||
return []
|
||||
}
|
||||
|
||||
return structuredClone(episode.chapters) || []
|
||||
}
|
||||
|
||||
getPlaybackTitle(episodeId) {
|
||||
const episode = this.podcastEpisodes.find((ep) => ep.id === episodeId)
|
||||
if (!episode) {
|
||||
Logger.error(`[Podcast] getPlaybackTitle: episode not found`, episodeId)
|
||||
return ''
|
||||
}
|
||||
|
||||
return episode.title
|
||||
}
|
||||
|
||||
getPlaybackAuthor() {
|
||||
return this.author
|
||||
}
|
||||
|
||||
getPlaybackDuration(episodeId) {
|
||||
const episode = this.podcastEpisodes.find((ep) => ep.id === episodeId)
|
||||
if (!episode) {
|
||||
Logger.error(`[Podcast] getPlaybackDuration: episode not found`, episodeId)
|
||||
return 0
|
||||
}
|
||||
|
||||
return episode.duration
|
||||
}
|
||||
|
||||
/**
|
||||
* Old model kept metadata in a separate object
|
||||
*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue