From 27fef5098379045931b3b65a2651ec29c9ffecfd Mon Sep 17 00:00:00 2001 From: Sam Osborne Date: Thu, 16 Jun 2022 13:48:37 -0700 Subject: [PATCH 1/2] retry search with clean title author --- server/finders/BookFinder.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/server/finders/BookFinder.js b/server/finders/BookFinder.js index 60b39838..fb00219f 100644 --- a/server/finders/BookFinder.js +++ b/server/finders/BookFinder.js @@ -180,11 +180,11 @@ class BookFinder { Logger.debug(`Book Search: title: "${title}", author: "${author}", provider: ${provider}`) if (provider === 'google') { - return this.getGoogleBooksResults(title, author) + books = this.getGoogleBooksResults(title, author) } else if (provider === 'audible') { - return this.getAudibleResults(title, author, asin) + books = this.getAudibleResults(title, author, asin) } else if (provider === 'itunes') { - return this.getiTunesAudiobooksResults(title, author) + books = this.getiTunesAudiobooksResults(title, author) } else if (provider === 'libgen') { books = await this.getLibGenResults(title, author, maxTitleDistance, maxAuthorDistance) } else if (provider === 'openlibrary') { @@ -208,6 +208,14 @@ class BookFinder { } } + if (!books.length && !options.currentlyTryingCleaned) { + Logger.debug(`Book Search, no matches.. checking cleaned title and author`) + options.currentlyTryingCleaned = true + return this.search(provider, this.cleanTitleForCompares(title), this.cleanAuthorForCompares(author), isbn, asin, options) + } + + if (provider in ["google", "audible", "itunes"]) return books + return books.sort((a, b) => { return a.totalDistance - b.totalDistance }) From 485888b2d9e6da6c3323a903dbb0d16c6c50d76c Mon Sep 17 00:00:00 2001 From: Sam Date: Thu, 16 Jun 2022 22:37:36 -0700 Subject: [PATCH 2/2] list includes syntax --- server/finders/BookFinder.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/finders/BookFinder.js b/server/finders/BookFinder.js index fb00219f..8fe3f647 100644 --- a/server/finders/BookFinder.js +++ b/server/finders/BookFinder.js @@ -214,7 +214,7 @@ class BookFinder { return this.search(provider, this.cleanTitleForCompares(title), this.cleanAuthorForCompares(author), isbn, asin, options) } - if (provider in ["google", "audible", "itunes"]) return books + if (["google", "audible", "itunes"].includes(provider)) return books return books.sort((a, b) => { return a.totalDistance - b.totalDistance