mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-12-15 16:29:37 +00:00
Add db migration file to change audiobooks to library items with new data model
This commit is contained in:
parent
65793f7109
commit
b97ed953f7
17 changed files with 719 additions and 127 deletions
|
|
@ -1,10 +1,12 @@
|
|||
const { getId } = require('../../utils/index')
|
||||
|
||||
class Author {
|
||||
constructor(author) {
|
||||
this.id = null
|
||||
this.asin = null
|
||||
this.name = null
|
||||
this.imagePath = null
|
||||
this.imageFullPath = null
|
||||
this.relImagePath = null
|
||||
this.addedAt = null
|
||||
this.updatedAt = null
|
||||
|
||||
|
|
@ -18,7 +20,7 @@ class Author {
|
|||
this.asin = author.asin
|
||||
this.name = author.name
|
||||
this.imagePath = author.imagePath
|
||||
this.imageFullPath = author.imageFullPath
|
||||
this.relImagePath = author.relImagePath
|
||||
this.addedAt = author.addedAt
|
||||
this.updatedAt = author.updatedAt
|
||||
}
|
||||
|
|
@ -29,9 +31,9 @@ class Author {
|
|||
asin: this.asin,
|
||||
name: this.name,
|
||||
imagePath: this.imagePath,
|
||||
imageFullPath: this.imageFullPath,
|
||||
relImagePath: this.relImagePath,
|
||||
addedAt: this.addedAt,
|
||||
updatedAt: this.updatedAt
|
||||
lastUpdate: this.updatedAt
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -41,5 +43,15 @@ class Author {
|
|||
name: this.name
|
||||
}
|
||||
}
|
||||
|
||||
setData(data) {
|
||||
this.id = getId('aut')
|
||||
this.name = data.name
|
||||
this.asin = data.asin || null
|
||||
this.imagePath = data.imagePath || null
|
||||
this.relImagePath = data.relImagePath || null
|
||||
this.addedAt = Date.now()
|
||||
this.updatedAt = Date.now()
|
||||
}
|
||||
}
|
||||
module.exports = Author
|
||||
|
|
@ -1,39 +1,41 @@
|
|||
const BookMetadata = require('../metadata/BookMetadata')
|
||||
const AudioFile = require('../files/AudioFile')
|
||||
const EBookFile = require('../files/EBookFile')
|
||||
const AudioTrack = require('../AudioTrack')
|
||||
|
||||
class Book {
|
||||
constructor(book) {
|
||||
this.metadata = null
|
||||
|
||||
this.coverPath = null
|
||||
this.relCoverPath = null
|
||||
this.tags = []
|
||||
this.audioFiles = []
|
||||
this.ebookFiles = []
|
||||
this.audioTracks = []
|
||||
this.chapters = []
|
||||
|
||||
if (books) {
|
||||
if (book) {
|
||||
this.construct(book)
|
||||
}
|
||||
}
|
||||
|
||||
construct(book) {
|
||||
this.metadata = new BookMetadata(book.metadata)
|
||||
this.coverPath = book.coverPath
|
||||
this.relCoverPath = book.relCoverPath
|
||||
this.tags = [...book.tags]
|
||||
this.audioFiles = book.audioFiles.map(f => new AudioFile(f))
|
||||
this.ebookFiles = book.ebookFiles.map(f => new EBookFile(f))
|
||||
this.audioTracks = book.audioTracks.map(a => new AudioTrack(a))
|
||||
this.chapters = book.chapters.map(c => ({ ...c }))
|
||||
}
|
||||
|
||||
toJSON() {
|
||||
return {
|
||||
metadata: this.metadata.toJSON(),
|
||||
coverPath: this.coverPath,
|
||||
relCoverPath: this.relCoverPath,
|
||||
tags: [...this.tags],
|
||||
audioFiles: this.audioFiles.map(f => f.toJSON()),
|
||||
ebookFiles: this.ebookFiles.map(f => f.toJSON()),
|
||||
audioTracks: this.audioTracks.map(a => a.toJSON()),
|
||||
chapters: this.chapters.map(c => ({ ...c }))
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,9 @@
|
|||
const { getId } = require('../../utils/index')
|
||||
|
||||
class Series {
|
||||
constructor(series) {
|
||||
this.id = null
|
||||
this.name = null
|
||||
this.sequence = null
|
||||
this.addedAt = null
|
||||
this.updatedAt = null
|
||||
|
||||
|
|
@ -14,7 +15,6 @@ class Series {
|
|||
construct(series) {
|
||||
this.id = series.id
|
||||
this.name = series.name
|
||||
this.sequence = series.sequence
|
||||
this.addedAt = series.addedAt
|
||||
this.updatedAt = series.updatedAt
|
||||
}
|
||||
|
|
@ -23,18 +23,24 @@ class Series {
|
|||
return {
|
||||
id: this.id,
|
||||
name: this.name,
|
||||
sequence: this.sequence,
|
||||
addedAt: this.addedAt,
|
||||
updatedAt: this.updatedAt
|
||||
}
|
||||
}
|
||||
|
||||
toJSONMinimal() {
|
||||
toJSONMinimal(sequence) {
|
||||
return {
|
||||
id: this.id,
|
||||
name: this.name,
|
||||
sequence: this.sequence
|
||||
sequence
|
||||
}
|
||||
}
|
||||
|
||||
setData(data) {
|
||||
this.id = getId('ser')
|
||||
this.name = data.name
|
||||
this.addedAt = Date.now()
|
||||
this.updatedAt = Date.now()
|
||||
}
|
||||
}
|
||||
module.exports = Series
|
||||
Loading…
Add table
Add a link
Reference in a new issue