From c5d668a841405730dd7e0b2f651acb767b2689fa Mon Sep 17 00:00:00 2001 From: Harmon Date: Wed, 26 Jul 2023 06:29:16 -0500 Subject: [PATCH] [Units] Improve coherence of search_wiki function --- units/wikis.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/units/wikis.py b/units/wikis.py index 3495a4803a..ed26907d47 100644 --- a/units/wikis.py +++ b/units/wikis.py @@ -239,7 +239,10 @@ async def search_wiki( # TODO: Handle bold (''' -> **) and italics ('' -> *) - thumbnail = page.get("thumbnail") + if (thumbnail := page.get("thumbnail")): + thumbnail = thumbnail["source"].replace( + f"{thumbnail['width']}px", "1200px" + ) logo = wiki_info_data["logo"] if logo.startswith("//"): @@ -254,11 +257,7 @@ async def search_wiki( title = page["title"], url = page["fullurl"], # TODO: Use canonicalurl? extract = extract, - image_url = ( - thumbnail["source"].replace( - f"{thumbnail['width']}px", "1200px" - ) if thumbnail else None - ), + image_url = thumbnail, wiki = wiki_info )