diff --git a/bookwyrm/connectors/inventaire.py b/bookwyrm/connectors/inventaire.py index 249f6b9ca..69524b222 100644 --- a/bookwyrm/connectors/inventaire.py +++ b/bookwyrm/connectors/inventaire.py @@ -222,9 +222,10 @@ class Connector(AbstractConnector): def get_description(self, links: JsonDict) -> str: """grab an extracted excerpt from wikipedia""" link = links.get("enwiki") - if not link: + if not link or not link.get("title"): return "" - url = f"{self.base_url}/api/data?action=wp-extract&lang=en&title={link}" + title = link.get("title") + url = f"{self.base_url}/api/data?action=wp-extract&lang=en&title={title}" try: data = get_data(url) except ConnectorException: diff --git a/bookwyrm/tests/connectors/test_inventaire_connector.py b/bookwyrm/tests/connectors/test_inventaire_connector.py index 7844f3919..1cd88195f 100644 --- a/bookwyrm/tests/connectors/test_inventaire_connector.py +++ b/bookwyrm/tests/connectors/test_inventaire_connector.py @@ -273,7 +273,9 @@ class Inventaire(TestCase): json={"extract": "hi hi"}, ) - extract = self.connector.get_description({"enwiki": "test_path"}) + extract = self.connector.get_description( + {"enwiki": {"title": "test_path", "badges": "hello"}} + ) self.assertEqual(extract, "hi hi") def test_remote_id_from_model(self):