[PR #795] [MERGED] Fix issue with unecessary empty search during match (Issue #794) #3426

Closed
opened 2026-04-25 00:15:36 +02:00 by adam · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/advplyr/audiobookshelf/pull/795
Author: @jmt-gh
Created: 6/30/2022
Status: Merged
Merged: 6/30/2022
Merged by: @advplyr

Base: masterHead: issue_794


📝 Commits (3)

  • 661778c Await the response from audible for book search by ASIN
  • b0684b6 Await the responses from googlebooks and itunes
  • 67396c1 formatting update

📊 Changes

1 file changed (+3 additions, -3 deletions)

View changed files

📝 server/finders/BookFinder.js (+3 -3)

📄 Description

This PR looks to resolve issue #794

We weren't properly awaiting the responses from the different provider search results. For iTunes and Google, this didn't result in any end user facing issue, but for Audible, it would cause an empty response to get returned after the actual response did when searching by ASIN.

I'm... not super confident in my understanding of async/await in JS, but this definitely seemed to cause some mildly unoptimal code. In the logs below, you can see in the After state, that we no longer need to unnecessarily do the 2nd search against "cleaned title and author" for any of the providers.

Before

Audible (search by ASIN)
[2022-06-29 19:27:22] DEBUG: Book Search: title: "B004TNLOV8", author: "", provider: audible
server/Logger.js:87
[2022-06-29 19:27:22] DEBUG: [Audible] ASIN url: https://api.audnex.us/books/B004TNLOV8
server/Logger.js:87
[2022-06-29 19:27:22] DEBUG: Book Search, no matches.. checking cleaned title and author
server/Logger.js:87
[2022-06-29 19:27:22] DEBUG: Book Search: title: "b004tnlov8", author: "", provider: audible
server/Logger.js:87
[2022-06-29 19:27:22] DEBUG: [Audible] Search url: https://api.audible.com/1.0/catalog/products?num_results=10&products_sort_by=Relevance&title=b004tnlov8
server/Logger.js:87
Google
[2022-06-29 19:26:57] DEBUG: Book Search: title: "Of Mice and Men", author: "john steinbeck", provider: google
server/Logger.js:87
[2022-06-29 19:26:57] DEBUG: [GoogleBooks] Search url: https://www.googleapis.com/books/v1/volumes?q=intitle:Of%20Mice%20and%20Men+inauthor:john%20steinbeck
server/Logger.js:87
[2022-06-29 19:26:57] DEBUG: Book Search, no matches.. checking cleaned title and author
server/Logger.js:87
[2022-06-29 19:26:57] DEBUG: Book Search: title: "of mice and men", author: "john steinbeck", provider: google
server/Logger.js:87
[2022-06-29 19:26:57] DEBUG: [GoogleBooks] Search url: https://www.googleapis.com/books/v1/volumes?q=intitle:of%20mice%20and%20men+inauthor:john%20steinbeck
iTunes
[2022-06-29 19:26:27] DEBUG: Book Search: title: "Of Mice and Men", author: "john steinbeck", provider: itunes
server/Logger.js:87
[2022-06-29 19:26:27] DEBUG: Book Search, no matches.. checking cleaned title and author
server/Logger.js:87
[2022-06-29 19:26:27] DEBUG: Book Search: title: "of mice and men", author: "john steinbeck", provider: itunes
server/Logger.js:87

After

Audible
[2022-06-29 19:23:45] DEBUG: Book Search: title: "B004TNLOV8", author: "", provider: audible
server/Logger.js:87
[2022-06-29 19:23:45] DEBUG: [Audible] ASIN url: https://api.audnex.us/books/B004TNLOV8
Google
[2022-06-29 19:24:36] DEBUG: Book Search: title: "Of Mice and Men", author: "john steinbeck", provider: google
server/Logger.js:87
[2022-06-29 19:24:36] DEBUG: [GoogleBooks] Search url: https://www.googleapis.com/books/v1/volumes?q=intitle:Of%20Mice%20and%20Men+inauthor:john%20steinbeck
server/Logger.js:87
iTunes
[2022-06-29 19:25:02] DEBUG: Book Search: title: "Of Mice and Men", author: "john steinbeck", provider: itunes
server/Logger.js:87

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/advplyr/audiobookshelf/pull/795 **Author:** [@jmt-gh](https://github.com/jmt-gh) **Created:** 6/30/2022 **Status:** ✅ Merged **Merged:** 6/30/2022 **Merged by:** [@advplyr](https://github.com/advplyr) **Base:** `master` ← **Head:** `issue_794` --- ### 📝 Commits (3) - [`661778c`](https://github.com/advplyr/audiobookshelf/commit/661778c02c8e51ce9a431e6c335d084ee4b6fc3d) Await the response from audible for book search by ASIN - [`b0684b6`](https://github.com/advplyr/audiobookshelf/commit/b0684b6f1b7aa065bdffdad3a10657f4350b9562) Await the responses from googlebooks and itunes - [`67396c1`](https://github.com/advplyr/audiobookshelf/commit/67396c16ddedc033a6eaffe5798a1714239f505c) formatting update ### 📊 Changes **1 file changed** (+3 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `server/finders/BookFinder.js` (+3 -3) </details> ### 📄 Description This PR looks to resolve issue #794 We weren't properly awaiting the responses from the different provider search results. For iTunes and Google, this didn't result in any end user facing issue, but for Audible, it would cause an empty response to get returned after the actual response did when searching by ASIN. I'm... not super confident in my understanding of async/await in JS, but this definitely seemed to cause some mildly unoptimal code. In the logs below, you can see in the After state, that we no longer need to unnecessarily do the 2nd search against "cleaned title and author" for any of the providers. **Before** ``` Audible (search by ASIN) [2022-06-29 19:27:22] DEBUG: Book Search: title: "B004TNLOV8", author: "", provider: audible server/Logger.js:87 [2022-06-29 19:27:22] DEBUG: [Audible] ASIN url: https://api.audnex.us/books/B004TNLOV8 server/Logger.js:87 [2022-06-29 19:27:22] DEBUG: Book Search, no matches.. checking cleaned title and author server/Logger.js:87 [2022-06-29 19:27:22] DEBUG: Book Search: title: "b004tnlov8", author: "", provider: audible server/Logger.js:87 [2022-06-29 19:27:22] DEBUG: [Audible] Search url: https://api.audible.com/1.0/catalog/products?num_results=10&products_sort_by=Relevance&title=b004tnlov8 server/Logger.js:87 ``` ``` Google [2022-06-29 19:26:57] DEBUG: Book Search: title: "Of Mice and Men", author: "john steinbeck", provider: google server/Logger.js:87 [2022-06-29 19:26:57] DEBUG: [GoogleBooks] Search url: https://www.googleapis.com/books/v1/volumes?q=intitle:Of%20Mice%20and%20Men+inauthor:john%20steinbeck server/Logger.js:87 [2022-06-29 19:26:57] DEBUG: Book Search, no matches.. checking cleaned title and author server/Logger.js:87 [2022-06-29 19:26:57] DEBUG: Book Search: title: "of mice and men", author: "john steinbeck", provider: google server/Logger.js:87 [2022-06-29 19:26:57] DEBUG: [GoogleBooks] Search url: https://www.googleapis.com/books/v1/volumes?q=intitle:of%20mice%20and%20men+inauthor:john%20steinbeck ``` ``` iTunes [2022-06-29 19:26:27] DEBUG: Book Search: title: "Of Mice and Men", author: "john steinbeck", provider: itunes server/Logger.js:87 [2022-06-29 19:26:27] DEBUG: Book Search, no matches.. checking cleaned title and author server/Logger.js:87 [2022-06-29 19:26:27] DEBUG: Book Search: title: "of mice and men", author: "john steinbeck", provider: itunes server/Logger.js:87 ``` **After** ``` Audible [2022-06-29 19:23:45] DEBUG: Book Search: title: "B004TNLOV8", author: "", provider: audible server/Logger.js:87 [2022-06-29 19:23:45] DEBUG: [Audible] ASIN url: https://api.audnex.us/books/B004TNLOV8 ``` ``` Google [2022-06-29 19:24:36] DEBUG: Book Search: title: "Of Mice and Men", author: "john steinbeck", provider: google server/Logger.js:87 [2022-06-29 19:24:36] DEBUG: [GoogleBooks] Search url: https://www.googleapis.com/books/v1/volumes?q=intitle:Of%20Mice%20and%20Men+inauthor:john%20steinbeck server/Logger.js:87 ``` ``` iTunes [2022-06-29 19:25:02] DEBUG: Book Search: title: "Of Mice and Men", author: "john steinbeck", provider: itunes server/Logger.js:87 ``` --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
adam added the pull-request label 2026-04-25 00:15:36 +02:00
adam closed this issue 2026-04-25 00:15:36 +02:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/audiobookshelf#3426