mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-07-16 12:24:56 +02:00
New data model change of Book media type to include array of Audiobook and Ebook objects
This commit is contained in:
parent
0af6ad63c1
commit
4fe60465e5
13 changed files with 677 additions and 334 deletions
70
server/objects/entities/EBook.js
Normal file
70
server/objects/entities/EBook.js
Normal file
|
@ -0,0 +1,70 @@
|
|||
const EBookFile = require('../files/EBookFile')
|
||||
const { areEquivalent, copyValue } = require('../../utils/index')
|
||||
|
||||
class EBook {
|
||||
constructor(ebook) {
|
||||
this.id = null
|
||||
this.index = null
|
||||
this.name = null
|
||||
this.ebookFile = null
|
||||
this.addedAt = null
|
||||
this.updatedAt = null
|
||||
|
||||
if (ebook) {
|
||||
this.construct(ebook)
|
||||
}
|
||||
}
|
||||
|
||||
construct(ebook) {
|
||||
this.id = ebook.id
|
||||
this.index = ebook.index
|
||||
this.name = ebook.name
|
||||
this.ebookFile = new EBookFile(ebook.ebookFile)
|
||||
this.addedAt = ebook.addedAt
|
||||
this.updatedAt = ebook.updatedAt
|
||||
}
|
||||
|
||||
toJSON() {
|
||||
return {
|
||||
id: this.id,
|
||||
index: this.index,
|
||||
name: this.name,
|
||||
ebookFile: this.ebookFile.toJSON(),
|
||||
addedAt: this.addedAt,
|
||||
updatedAt: this.updatedAt
|
||||
}
|
||||
}
|
||||
|
||||
toJSONMinified() {
|
||||
return {
|
||||
id: this.id,
|
||||
index: this.index,
|
||||
name: this.name,
|
||||
ebookFormat: this.ebookFile.ebookFormat,
|
||||
addedAt: this.addedAt,
|
||||
updatedAt: this.updatedAt,
|
||||
size: this.size
|
||||
}
|
||||
}
|
||||
|
||||
toJSONMinified() {
|
||||
return {
|
||||
id: this.id,
|
||||
index: this.index,
|
||||
name: this.name,
|
||||
ebookFile: this.ebookFile.toJSON(),
|
||||
addedAt: this.addedAt,
|
||||
updatedAt: this.updatedAt,
|
||||
size: this.size
|
||||
}
|
||||
}
|
||||
|
||||
get size() {
|
||||
return this.ebookFile.metadata.size
|
||||
}
|
||||
|
||||
findFileWithInode(inode) {
|
||||
return this.ebookFile.ino === inode
|
||||
}
|
||||
}
|
||||
module.exports = EBook
|
Loading…
Add table
Add a link
Reference in a new issue