mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-07-19 18:34:25 +02:00
Start of new data model
This commit is contained in:
parent
2b7f53b0a7
commit
65793f7109
18 changed files with 672 additions and 8 deletions
56
server/objects/metadata/BookMetadata.js
Normal file
56
server/objects/metadata/BookMetadata.js
Normal file
|
@ -0,0 +1,56 @@
|
|||
class BookMetadata {
|
||||
constructor(metadata) {
|
||||
this.title = null
|
||||
this.subtitle = null
|
||||
this.authors = []
|
||||
this.narrators = [] // Array of strings
|
||||
this.series = []
|
||||
this.genres = [] // Array of strings
|
||||
this.publishedYear = null
|
||||
this.publishedDate = null
|
||||
this.publisher = null
|
||||
this.description = null
|
||||
this.isbn = null
|
||||
this.asin = null
|
||||
this.language = null
|
||||
|
||||
if (metadata) {
|
||||
this.construct(metadata)
|
||||
}
|
||||
}
|
||||
|
||||
construct(metadata) {
|
||||
this.title = metadata.title
|
||||
this.subtitle = metadata.subtitle
|
||||
this.authors = metadata.authors.map(a => ({ ...a }))
|
||||
this.narrators = [...metadata.narrators]
|
||||
this.series = metadata.series.map(s => ({ ...s }))
|
||||
this.genres = [...metadata.genres]
|
||||
this.publishedYear = metadata.publishedYear
|
||||
this.publishedDate = metadata.publishedDate
|
||||
this.publisher = metadata.publisher
|
||||
this.description = metadata.description
|
||||
this.isbn = metadata.isbn
|
||||
this.asin = metadata.asin
|
||||
this.language = metadata.language
|
||||
}
|
||||
|
||||
toJSON() {
|
||||
return {
|
||||
title: this.title,
|
||||
subtitle: this.subtitle,
|
||||
authors: this.authors.map(a => ({ ...a })), // Author JSONMinimal with name and id
|
||||
narrators: [...this.narrators],
|
||||
series: this.series.map(s => ({ ...s })),
|
||||
genres: [...this.genres],
|
||||
publishedYear: this.publishedYear,
|
||||
publishedDate: this.publishedDate,
|
||||
publisher: this.publisher,
|
||||
description: this.description,
|
||||
isbn: this.isbn,
|
||||
asin: this.asin,
|
||||
language: this.language
|
||||
}
|
||||
}
|
||||
}
|
||||
module.exports = BookMetadata
|
Loading…
Add table
Add a link
Reference in a new issue