From 275670f4016c2bbf826450692dfd4b0ecfd7808a Mon Sep 17 00:00:00 2001 From: Brendan Howell Date: Sat, 20 Jun 2020 11:51:40 +0200 Subject: [PATCH] handle errors for OpenGraph image downloads --- screenless/bureau/publications/publications.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/screenless/bureau/publications/publications.py b/screenless/bureau/publications/publications.py index 0bca42d..9f8dfa1 100644 --- a/screenless/bureau/publications/publications.py +++ b/screenless/bureau/publications/publications.py @@ -334,9 +334,13 @@ class Publications(Bureau): if len(fileext) > 4: fileext = ".jpg" filename = tempfile.mktemp(fileext) - print("fetching", entry.img, filename) - urllib.request.urlretrieve(entry.img, filename) - entry.img = "file://" + filename + try: + print("fetching", entry.img, filename) + urllib.request.urlretrieve(entry.img, filename) + entry.img = "file://" + filename + except urllib.error.HTTPError as err: + self.log.error(err) + entry.img = "" return entry