mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-12-09 13:29:37 +00:00
Add:Support volumes with decimal #196, Change:Time remaining adjusted for current playback rate, Change:Series bookshelf shows shelf label with series name, Fix:Search bookshelf UI, Add:Show current chapter under audio track, Change: Highlight colors for chapters modal
This commit is contained in:
parent
24d2e09724
commit
ad8670aeb4
12 changed files with 101 additions and 44 deletions
33
server/scanner/AuthorScanner.js
Normal file
33
server/scanner/AuthorScanner.js
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
const AuthorFinder = require('../AuthorFinder')
|
||||
|
||||
class AuthorScanner {
|
||||
constructor(db, MetadataPath) {
|
||||
this.db = db
|
||||
this.MetadataPath = MetadataPath
|
||||
this.authorFinder = new AuthorFinder(MetadataPath)
|
||||
}
|
||||
|
||||
getUniqueAuthors() {
|
||||
var authorFls = this.db.audiobooks.map(b => b.book.authorFL)
|
||||
var authors = []
|
||||
authorFls.forEach((auth) => {
|
||||
authors = authors.concat(auth.split(', ').map(a => a.trim()))
|
||||
})
|
||||
return [...new Set(authors)]
|
||||
}
|
||||
|
||||
async scanAuthors() {
|
||||
var authors = this.getUniqueAuthors()
|
||||
for (let i = 0; i < authors.length; i++) {
|
||||
var authorName = authors[i]
|
||||
var author = await this.authorFinder.getAuthorByName(authorName)
|
||||
if (!author) {
|
||||
return res.status(500).send('Failed to create author')
|
||||
}
|
||||
|
||||
await this.db.insertEntity('author', author)
|
||||
this.emitter('author_added', author.toJSON())
|
||||
}
|
||||
}
|
||||
}
|
||||
module.exports = AuthorScanner
|
||||
Loading…
Add table
Add a link
Reference in a new issue