mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2024-12-20 19:06:06 +01:00
add Database.getLibraryItemCoverPath
This commit is contained in:
parent
50fd659749
commit
431ae97593
@ -808,6 +808,28 @@ class Database {
|
|||||||
return `${normalizedColumn} LIKE ${pattern}`
|
return `${normalizedColumn} LIKE ${pattern}`
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async getLibraryItemCoverPath(libraryItemId) {
|
||||||
|
const libraryItem = await this.libraryItemModel.findByPk(libraryItemId, {
|
||||||
|
attributes: ['id', 'mediaType', 'mediaId', 'libraryId'],
|
||||||
|
include: [
|
||||||
|
{
|
||||||
|
model: this.bookModel,
|
||||||
|
attributes: ['id', 'coverPath']
|
||||||
|
},
|
||||||
|
{
|
||||||
|
model: this.podcastModel,
|
||||||
|
attributes: ['id', 'coverPath']
|
||||||
|
}
|
||||||
|
]
|
||||||
|
})
|
||||||
|
if (!libraryItem) {
|
||||||
|
Logger.warn(`[Database] getCover: Library item "${libraryItemId}" does not exist`)
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
return libraryItem.media.coverPath
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = new Database()
|
module.exports = new Database()
|
||||||
|
Loading…
Reference in New Issue
Block a user