mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2026-07-13 08:12:52 +02:00
Update:Match author use closest name match by levenshtein distance #2624
This commit is contained in:
@@ -15,12 +15,19 @@ class AuthorFinder {
|
||||
return this.audnexus.findAuthorByASIN(asin, region)
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {string} name
|
||||
* @param {string} region
|
||||
* @param {Object} [options={}]
|
||||
* @returns {Promise<import('../providers/Audnexus').AuthorSearchObj>}
|
||||
*/
|
||||
async findAuthorByName(name, region, options = {}) {
|
||||
if (!name) return null
|
||||
const maxLevenshtein = !isNaN(options.maxLevenshtein) ? Number(options.maxLevenshtein) : 3
|
||||
|
||||
const author = await this.audnexus.findAuthorByName(name, region, maxLevenshtein)
|
||||
if (!author || !author.name) {
|
||||
if (!author?.name) {
|
||||
return null
|
||||
}
|
||||
return author
|
||||
|
||||
Reference in New Issue
Block a user