mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-08-01 08:44:40 +02:00
add Database.getLibraryItemCoverPath
This commit is contained in:
parent
50fd659749
commit
431ae97593
1 changed files with 22 additions and 0 deletions
|
@ -808,6 +808,28 @@ class Database {
|
|||
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()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue