mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-07-21 11:24:53 +02:00
Update:Prefer epub ebook file when setting ebook #1825, validate ebookLocation
This commit is contained in:
parent
9547824aaa
commit
fde07d26e5
4 changed files with 27 additions and 12 deletions
|
@ -437,16 +437,19 @@ class LibraryItem {
|
|||
|
||||
if (this.mediaType === 'book') {
|
||||
// Add/update ebook file (ebooks that were removed are removed in checkScanData)
|
||||
this.libraryFiles.forEach((lf) => {
|
||||
if (lf.fileType === 'ebook') {
|
||||
if (!this.media.ebookFile) {
|
||||
this.media.setEbookFile(lf)
|
||||
hasUpdated = true
|
||||
} else if (this.media.ebookFile.ino == lf.ino && this.media.ebookFile.updateFromLibraryFile(lf)) { // Update existing ebookFile
|
||||
hasUpdated = true
|
||||
}
|
||||
if (this.media.ebookFile) {
|
||||
const matchingLibraryFile = this.libraryFiles.find(lf => lf.ino === this.media.ebookFile.ino)
|
||||
if (matchingLibraryFile && this.media.ebookFile.updateFromLibraryFile(matchingLibraryFile)) {
|
||||
hasUpdated = true
|
||||
}
|
||||
})
|
||||
} else {
|
||||
// Prefer epub ebook then fallback to first other ebook file
|
||||
const ebookLibraryFile = this.libraryFiles.find(lf => lf.isEBookFile && lf.metadata.format === 'epub') || this.libraryFiles.find(lf => lf.isEBookFile)
|
||||
if (ebookLibraryFile) {
|
||||
this.media.setEbookFile(ebookLibraryFile)
|
||||
hasUpdated = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Set cover image if not set
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue