Refactor Feed model to create new feed for library item

This commit is contained in:
advplyr
2024-12-14 16:55:56 -06:00
parent c4610e6102
commit 9bd1f9e3d5
7 changed files with 400 additions and 112 deletions

View File

@ -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