From 7a573682f11991720931e62651b644928158e076 Mon Sep 17 00:00:00 2001 From: "Renato \"Lond\" Cerqueira" Date: Tue, 28 Jan 2025 12:19:22 +0100 Subject: [PATCH] Fix isbn search, matching the regular search --- bookwyrm/connectors/openlibrary.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/bookwyrm/connectors/openlibrary.py b/bookwyrm/connectors/openlibrary.py index 4dc6d6ac1..fcdc4c7db 100644 --- a/bookwyrm/connectors/openlibrary.py +++ b/bookwyrm/connectors/openlibrary.py @@ -181,17 +181,19 @@ class Connector(AbstractConnector): ) def parse_isbn_search_data(self, data: JsonDict) -> Iterator[SearchResult]: - for search_result in list(data.values()): + for search_result in list(data.get("docs", [])): # build the remote id from the openlibrary key key = self.books_url + search_result["key"] - authors = search_result.get("authors") or [{"name": "Unknown"}] - author_names = [author.get("name") for author in authors] + authors = search_result.get("author_name") or ["Unknown"] + cover_blob = search_result.get("cover_i") + cover = self.get_cover_url([cover_blob], size="M") if cover_blob else None yield SearchResult( title=search_result.get("title"), key=key, - author=", ".join(author_names), + author=", ".join(authors), connector=self, - year=search_result.get("publish_date"), + year=search_result.get("first_publish_year"), + cover=cover, ) def load_edition_data(self, olkey: str) -> JsonDict: