diff --git a/server/objects/files/EBookFile.js b/server/objects/files/EBookFile.js index a3558a8884..ae40dc8844 100644 --- a/server/objects/files/EBookFile.js +++ b/server/objects/files/EBookFile.js @@ -16,7 +16,7 @@ class EBookFile { construct(file) { this.ino = file.ino this.metadata = new FileMetadata(file.metadata) - this.ebookFormat = file.ebookFormat + this.ebookFormat = file.ebookFormat || this.metadata.format this.addedAt = file.addedAt this.updatedAt = file.updatedAt } diff --git a/server/objects/mediaTypes/Book.js b/server/objects/mediaTypes/Book.js index e9eec4512a..598c226502 100644 --- a/server/objects/mediaTypes/Book.js +++ b/server/objects/mediaTypes/Book.js @@ -73,7 +73,7 @@ class Book { numInvalidAudioFiles: this.invalidAudioFiles.length, duration: this.duration, size: this.size, - ebookFormat: this.ebookFile ? this.ebookFile.ebookFormat : null + ebookFormat: this.ebookFile?.ebookFormat } } @@ -90,7 +90,7 @@ class Book { size: this.size, tracks: this.tracks.map(t => t.toJSON()), missingParts: [...this.missingParts], - ebookFile: this.ebookFile ? this.ebookFile.toJSON() : null + ebookFile: this.ebookFile?.toJSON() || null } } diff --git a/server/scanner/BookScanner.js b/server/scanner/BookScanner.js index ed905a03d8..1e51cf5262 100644 --- a/server/scanner/BookScanner.js +++ b/server/scanner/BookScanner.js @@ -160,6 +160,7 @@ class BookScanner { // Prefer to use an epub ebook then fallback to the first ebook found let ebookLibraryFile = libraryItemData.ebookLibraryFiles.find(lf => lf.metadata.ext.slice(1).toLowerCase() === 'epub') if (!ebookLibraryFile) ebookLibraryFile = libraryItemData.ebookLibraryFiles[0] + ebookLibraryFile = ebookLibraryFile.toJSON() // Ebook file is the same as library file except for additional `ebookFormat` ebookLibraryFile.ebookFormat = ebookLibraryFile.metadata.ext.slice(1).toLowerCase() media.ebookFile = ebookLibraryFile @@ -386,6 +387,7 @@ class BookScanner { } if (ebookLibraryFile) { + ebookLibraryFile = ebookLibraryFile.toJSON() ebookLibraryFile.ebookFormat = ebookLibraryFile.metadata.ext.slice(1).toLowerCase() } diff --git a/server/scanner/LibraryItemScanData.js b/server/scanner/LibraryItemScanData.js index cae2c70ec1..7bfcdefcae 100644 --- a/server/scanner/LibraryItemScanData.js +++ b/server/scanner/LibraryItemScanData.js @@ -102,7 +102,7 @@ class LibraryItemScanData { return this.libraryFiles.filter(lf => globals.SupportedImageTypes.includes(lf.metadata.ext?.slice(1).toLowerCase() || '')) } - /** @type {LibraryItem.LibraryFileObject[]} */ + /** @type {import('../objects/files/LibraryFile')[]} */ get ebookLibraryFiles() { return this.libraryFiles.filter(lf => globals.SupportedEbookTypes.includes(lf.metadata.ext?.slice(1).toLowerCase() || '')) }