mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-07-24 04:44:57 +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
|
@ -106,6 +106,9 @@ class Book extends Model {
|
|||
this.updatedAt
|
||||
/** @type {Date} */
|
||||
this.createdAt
|
||||
|
||||
/** @type {import('./Author')[]} - optional if expanded */
|
||||
this.authors
|
||||
}
|
||||
|
||||
static getOldBook(libraryItemExpanded) {
|
||||
|
@ -320,6 +323,32 @@ class Book extends Model {
|
|||
}
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Comma separated array of author names
|
||||
* Requires authors to be loaded
|
||||
*
|
||||
* @returns {string}
|
||||
*/
|
||||
get authorName() {
|
||||
if (this.authors === undefined) {
|
||||
Logger.error(`[Book] authorName: Cannot get authorName because authors are not loaded`)
|
||||
return ''
|
||||
}
|
||||
return this.authors.map((au) => au.name).join(', ')
|
||||
}
|
||||
get includedAudioFiles() {
|
||||
return this.audioFiles.filter((af) => !af.exclude)
|
||||
}
|
||||
get trackList() {
|
||||
let startOffset = 0
|
||||
return this.includedAudioFiles.map((af) => {
|
||||
const track = structuredClone(af)
|
||||
track.startOffset = startOffset
|
||||
startOffset += track.duration
|
||||
return track
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Book
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue