mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-08-29 06:18:21 +02:00
Refactor Feed model to create new feed for library item
This commit is contained in:
parent
c4610e6102
commit
9bd1f9e3d5
7 changed files with 400 additions and 112 deletions
|
@ -73,6 +73,9 @@ class LibraryItem extends Model {
|
|||
this.createdAt
|
||||
/** @type {Date} */
|
||||
this.updatedAt
|
||||
|
||||
/** @type {Book.BookExpanded|Podcast.PodcastExpanded} - only set when expanded */
|
||||
this.media
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1124,6 +1127,24 @@ class LibraryItem extends Model {
|
|||
}
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if book or podcast library item has audio tracks
|
||||
* Requires expanded library item
|
||||
*
|
||||
* @returns {boolean}
|
||||
*/
|
||||
hasAudioTracks() {
|
||||
if (!this.media) {
|
||||
Logger.error(`[LibraryItem] hasAudioTracks: Library item "${this.id}" does not have media`)
|
||||
return false
|
||||
}
|
||||
if (this.mediaType === 'book') {
|
||||
return this.media.audioFiles?.length > 0
|
||||
} else {
|
||||
return this.media.podcastEpisodes?.length > 0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = LibraryItem
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue