Add:Cover image cache, resize & use webp image #223

This commit is contained in:
advplyr 2021-12-12 17:15:37 -06:00
parent d04f3450ec
commit ddf0fa72e8
14 changed files with 360 additions and 108 deletions

View file

@ -10,8 +10,10 @@ const { CoverDestination } = require('./utils/constants')
const { downloadFile } = require('./utils/fileUtils')
class CoverController {
constructor(db, MetadataPath, AudiobookPath) {
constructor(db, cacheManager, MetadataPath, AudiobookPath) {
this.db = db
this.cacheManager = cacheManager
this.MetadataPath = MetadataPath.replace(/\\/g, '/')
this.BookMetadataPath = Path.posix.join(this.MetadataPath, 'books')
this.AudiobookPath = AudiobookPath
@ -115,6 +117,7 @@ class CoverController {
}
await this.removeOldCovers(fullPath, extname)
await this.cacheManager.purgeCoverCache(audiobook.id)
Logger.info(`[CoverController] Uploaded audiobook cover "${coverPath}" for "${audiobook.title}"`)
@ -152,6 +155,7 @@ class CoverController {
await fs.rename(temppath, coverFullPath)
await this.removeOldCovers(fullPath, '.' + imgtype.ext)
await this.cacheManager.purgeCoverCache(audiobook.id)
Logger.info(`[CoverController] Downloaded audiobook cover "${coverPath}" from url "${url}" for "${audiobook.title}"`)