mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-08-05 18:54:39 +02:00
New data model authors routes
This commit is contained in:
parent
65df377a49
commit
dad12537b6
6 changed files with 102 additions and 65 deletions
|
@ -31,6 +31,27 @@ class AuthorFinder {
|
|||
return author
|
||||
}
|
||||
|
||||
async saveAuthorImage(authorId, url) {
|
||||
var authorDir = this.AuthorPath
|
||||
var relAuthorDir = Path.posix.join('/metadata', 'authors')
|
||||
await fs.ensureDir(authorDir)
|
||||
|
||||
var imageExtension = url.toLowerCase().split('.').pop()
|
||||
var ext = imageExtension === 'png' ? 'png' : 'jpg'
|
||||
var filename = authorId + '.' + ext
|
||||
var outputPath = Path.posix.join(authorDir, filename)
|
||||
var relPath = Path.posix.join(relAuthorDir, filename)
|
||||
|
||||
var success = await this.downloadImage(url, outputPath)
|
||||
if (!success) {
|
||||
return null
|
||||
}
|
||||
return {
|
||||
path: outputPath,
|
||||
relPath
|
||||
}
|
||||
}
|
||||
|
||||
async createAuthor(payload) {
|
||||
if (!payload || !payload.name) return null
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue