mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-07-02 21:44:56 +02:00
New data model save covers, scanner, new api routes
This commit is contained in:
parent
5f4e5cd3d8
commit
73257188f6
37 changed files with 1649 additions and 672 deletions
|
@ -1,3 +1,5 @@
|
|||
const Path = require('path')
|
||||
const { getFileTimestampsWithIno } = require('../../utils/fileUtils')
|
||||
const globals = require('../../utils/globals')
|
||||
const FileMetadata = require('../metadata/FileMetadata')
|
||||
|
||||
|
@ -30,6 +32,10 @@ class LibraryFile {
|
|||
}
|
||||
}
|
||||
|
||||
clone() {
|
||||
return new LibraryFile(this.toJSON())
|
||||
}
|
||||
|
||||
get fileType() {
|
||||
if (globals.SupportedImageTypes.includes(this.metadata.format)) return 'image'
|
||||
if (globals.SupportedAudioTypes.includes(this.metadata.format)) return 'audio'
|
||||
|
@ -38,5 +44,27 @@ class LibraryFile {
|
|||
if (globals.MetadataFileTypes.includes(this.metadata.format)) return 'metadata'
|
||||
return 'unknown'
|
||||
}
|
||||
|
||||
get isMediaFile() {
|
||||
return this.fileType === 'audio' || this.fileType === 'ebook'
|
||||
}
|
||||
|
||||
get isOPFFile() {
|
||||
return this.metadata.ext === '.opf'
|
||||
}
|
||||
|
||||
async setDataFromPath(path, relPath) {
|
||||
var fileTsData = await getFileTimestampsWithIno(path)
|
||||
var fileMetadata = new FileMetadata()
|
||||
fileMetadata.setData(fileTsData)
|
||||
fileMetadata.filename = Path.basename(relPath)
|
||||
fileMetadata.path = path
|
||||
fileMetadata.relPath = relPath
|
||||
fileMetadata.ext = Path.extname(relPath)
|
||||
this.ino = fileTsData.ino
|
||||
this.metadata = fileMetadata
|
||||
this.addedAt = Date.now()
|
||||
this.updatedAt = Date.now()
|
||||
}
|
||||
}
|
||||
module.exports = LibraryFile
|
Loading…
Add table
Add a link
Reference in a new issue