diff --git a/server/controllers/SearchController.js b/server/controllers/SearchController.js index 86558846d..ecd9a41c0 100644 --- a/server/controllers/SearchController.js +++ b/server/controllers/SearchController.js @@ -88,10 +88,10 @@ class SearchController { const provider = getQueryParamAsString(query, 'provider', 'google') const title = getQueryParamAsString(query, 'title', '') const author = getQueryParamAsString(query, 'author', '') - const id = getQueryParamAsString(query, 'id', '', true) + const id = getQueryParamAsString(query, 'id', undefined) // Fetch library item - const libraryItem = await SearchController.fetchLibraryItem(id) + const libraryItem = id ? await SearchController.fetchLibraryItem(id) : null const results = await BookFinder.search(libraryItem, provider, title, author) res.json(results) diff --git a/server/finders/BookFinder.js b/server/finders/BookFinder.js index fe1a61027..6d31b2ab9 100644 --- a/server/finders/BookFinder.js +++ b/server/finders/BookFinder.js @@ -428,7 +428,7 @@ class BookFinder { } } - if (books.length) { + if (books.length && libraryItem) { const isAudibleProvider = provider.startsWith('audible') const libraryItemDurationMinutes = libraryItem?.media?.duration ? libraryItem.media.duration / 60 : null