mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-09-01 08:15:15 +02:00
Update new library scanner for scanning in new books
This commit is contained in:
parent
75276f5a44
commit
0ecfdab463
13 changed files with 694 additions and 35 deletions
|
@ -10,6 +10,8 @@ class LibraryItemScanData {
|
|||
/** @type {string} */
|
||||
this.libraryId = data.libraryId
|
||||
/** @type {string} */
|
||||
this.mediaType = data.mediaType
|
||||
/** @type {string} */
|
||||
this.ino = data.ino
|
||||
/** @type {number} */
|
||||
this.mtimeMs = data.mtimeMs
|
||||
|
@ -23,7 +25,7 @@ class LibraryItemScanData {
|
|||
this.relPath = data.relPath
|
||||
/** @type {boolean} */
|
||||
this.isFile = data.isFile
|
||||
/** @type {{title:string, subtitle:string, series:string, sequence:string, publishedYear:string, narrators:string}} */
|
||||
/** @type {{author:string, title:string, subtitle:string, series:string, sequence:string, publishedYear:string, narrators:string}} */
|
||||
this.mediaMetadata = data.mediaMetadata
|
||||
/** @type {import('../objects/files/LibraryFile')[]} */
|
||||
this.libraryFiles = data.libraryFiles
|
||||
|
@ -41,6 +43,30 @@ class LibraryItemScanData {
|
|||
this.libraryFilesModified = []
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to create a library item
|
||||
*/
|
||||
get libraryItemObject() {
|
||||
let size = 0
|
||||
this.libraryFiles.forEach((lf) => size += (!isNaN(lf.metadata.size) ? Number(lf.metadata.size) : 0))
|
||||
return {
|
||||
ino: this.ino,
|
||||
path: this.path,
|
||||
relPath: this.relPath,
|
||||
mediaType: this.mediaType,
|
||||
isFile: this.isFile,
|
||||
mtime: this.mtimeMs,
|
||||
ctime: this.ctime,
|
||||
birthtime: this.birthtimeMs,
|
||||
lastScan: Date.now(),
|
||||
lastScanVersion: packageJson.version,
|
||||
libraryFiles: this.libraryFiles,
|
||||
libraryId: this.libraryId,
|
||||
libraryFolderId: this.libraryFolderId,
|
||||
size
|
||||
}
|
||||
}
|
||||
|
||||
/** @type {boolean} */
|
||||
get hasLibraryFileChanges() {
|
||||
return this.libraryFilesRemoved.length + this.libraryFilesModified.length + this.libraryFilesAdded.length
|
||||
|
@ -81,6 +107,31 @@ class LibraryItemScanData {
|
|||
return this.libraryFiles.filter(lf => globals.SupportedEbookTypes.includes(lf.metadata.ext?.slice(1).toLowerCase() || ''))
|
||||
}
|
||||
|
||||
/** @type {LibraryItem.LibraryFileObject} */
|
||||
get descTxtLibraryFile() {
|
||||
return this.libraryFiles.find(lf => lf.metadata.filename === 'desc.txt')
|
||||
}
|
||||
|
||||
/** @type {LibraryItem.LibraryFileObject} */
|
||||
get readerTxtLibraryFile() {
|
||||
return this.libraryFiles.find(lf => lf.metadata.filename === 'reader.txt')
|
||||
}
|
||||
|
||||
/** @type {LibraryItem.LibraryFileObject} */
|
||||
get metadataAbsLibraryFile() {
|
||||
return this.libraryFiles.find(lf => lf.metadata.filename === 'metadata.abs')
|
||||
}
|
||||
|
||||
/** @type {LibraryItem.LibraryFileObject} */
|
||||
get metadataJsonLibraryFile() {
|
||||
return this.libraryFiles.find(lf => lf.metadata.filename === 'metadata.json')
|
||||
}
|
||||
|
||||
/** @type {LibraryItem.LibraryFileObject} */
|
||||
get metadataOpfLibraryFile() {
|
||||
return this.libraryFiles.find(lf => lf.metadata.ext.toLowerCase() === '.opf')
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {LibraryItem} existingLibraryItem
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue