mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-12-15 08:19:37 +00:00
Update:Match author use closest name match by levenshtein distance #2624
This commit is contained in:
parent
58598bfcf2
commit
acf75abdf1
2 changed files with 56 additions and 8 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue