Skip to content

Commit

Permalink
Fix:Set ebookFormat on scans advplyr#2126
Browse files Browse the repository at this point in the history
  • Loading branch information
advplyr committed Sep 19, 2023
1 parent 604f527 commit 9967a5d
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion server/objects/files/EBookFile.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
4 changes: 2 additions & 2 deletions server/objects/mediaTypes/Book.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

Expand All @@ -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
}
}

Expand Down
2 changes: 2 additions & 0 deletions server/scanner/BookScanner.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -386,6 +387,7 @@ class BookScanner {
}

if (ebookLibraryFile) {
ebookLibraryFile = ebookLibraryFile.toJSON()
ebookLibraryFile.ebookFormat = ebookLibraryFile.metadata.ext.slice(1).toLowerCase()
}

Expand Down
2 changes: 1 addition & 1 deletion server/scanner/LibraryItemScanData.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() || ''))
}
Expand Down

0 comments on commit 9967a5d

Please sign in to comment.