From c3d0e8e7f70e9c6f687163a0541802e4f79cd55b Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Mon, 21 Dec 2020 11:47:47 -0800 Subject: [PATCH 1/2] Fixes openlibrary import to prefer editions with covers --- bookwyrm/connectors/abstract_connector.py | 2 +- bookwyrm/connectors/openlibrary.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bookwyrm/connectors/abstract_connector.py b/bookwyrm/connectors/abstract_connector.py index 5afd1089..86ac7435 100644 --- a/bookwyrm/connectors/abstract_connector.py +++ b/bookwyrm/connectors/abstract_connector.py @@ -140,7 +140,7 @@ class AbstractConnector(AbstractMinimalConnector): for author in self.get_authors_from_data(edition_data): edition.authors.add(author) if not edition.authors.exists() and work.authors.exists(): - edition.authors.add(work.authors.all()) + edition.authors.set(work.authors.all()) return edition diff --git a/bookwyrm/connectors/openlibrary.py b/bookwyrm/connectors/openlibrary.py index 74f76668..3b60c307 100644 --- a/bookwyrm/connectors/openlibrary.py +++ b/bookwyrm/connectors/openlibrary.py @@ -174,7 +174,7 @@ def pick_default_edition(options): if len(options) == 1: return options[0] - options = [e for e in options if e.get('cover')] or options + options = [e for e in options if e.get('covers')] or options options = [e for e in options if \ '/languages/eng' in str(e.get('languages'))] or options formats = ['paperback', 'hardcover', 'mass market paperback'] From 862f1d2580eda909db10acf68218a84ee3c08220 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Mon, 21 Dec 2020 12:22:47 -0800 Subject: [PATCH 2/2] Fixes cover unit test --- bookwyrm/tests/connectors/test_openlibrary_connector.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bookwyrm/tests/connectors/test_openlibrary_connector.py b/bookwyrm/tests/connectors/test_openlibrary_connector.py index b3d97ba3..e2d54cd3 100644 --- a/bookwyrm/tests/connectors/test_openlibrary_connector.py +++ b/bookwyrm/tests/connectors/test_openlibrary_connector.py @@ -44,7 +44,7 @@ class Openlibrary(TestCase): def test_pick_default_edition(self): edition = pick_default_edition(self.edition_list_data['entries']) - self.assertEqual(edition['key'], '/books/OL9952943M') + self.assertEqual(edition['key'], '/books/OL9788823M') def test_format_search_result(self):