From 6dc0c2c367ca1118bb3d31555fee2786522a32a3 Mon Sep 17 00:00:00 2001 From: Morgan McMillian Date: Wed, 24 Feb 2021 20:36:16 -0800 Subject: [PATCH] fallback if thumbnail not present --- src/widgets.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/widgets.py b/src/widgets.py index 42005a1..75d4dd8 100644 --- a/src/widgets.py +++ b/src/widgets.py @@ -502,9 +502,14 @@ class PostItem(Gtk.ListBoxRow): return scaled_img def get_oembed_thumb(self, oembed): - url = oembed.thumbnail_url - old_width = oembed.thumbnail_width - old_height = oembed.thumbnail_height + if 'thumbnail_url' in oembed: + url = oembed.thumbnail_url + old_width = oembed.thumbnail_width + old_height = oembed.thumbnail_height + else: + url = oembed.url + old_width = oembed.width + old_height = oembed.height ratio = old_width / old_height new_height = 256 / ratio r = requests.get(url)