Update new library scanner for scanning in new books

This commit is contained in:
advplyr
2023-09-01 18:01:17 -05:00
parent 75276f5a44
commit 0ecfdab463
13 changed files with 694 additions and 35 deletions

View File

@@ -270,5 +270,33 @@ class CoverManager {
}
return false
}
static async saveEmbeddedCoverArtNew(audioFiles, libraryItemId, libraryItemPath) {
let audioFileWithCover = audioFiles.find(af => af.embeddedCoverArt)
if (!audioFileWithCover) return null
let coverDirPath = null
if (global.ServerSettings.storeCoverWithItem && libraryItemPath) {
coverDirPath = libraryItemPath
} else {
coverDirPath = Path.posix.join(this.ItemMetadataPath, libraryItemId)
}
await fs.ensureDir(coverDirPath)
const coverFilename = audioFileWithCover.embeddedCoverArt === 'png' ? 'cover.png' : 'cover.jpg'
const coverFilePath = Path.join(coverDirPath, coverFilename)
const coverAlreadyExists = await fs.pathExists(coverFilePath)
if (coverAlreadyExists) {
Logger.warn(`[CoverManager] Extract embedded cover art but cover already exists for "${libraryItemPath}" - bail`)
return null
}
const success = await extractCoverArt(audioFileWithCover.metadata.path, coverFilePath)
if (success) {
return coverFilePath
}
return null
}
}
module.exports = CoverManager