From e4fc5e415168e02b4277e3cf42e92e6041e32c5a Mon Sep 17 00:00:00 2001 From: sudo killall windows <51250021+RhinoCodes@users.noreply.github.com> Date: Fri, 10 Jun 2022 11:20:40 -0500 Subject: [PATCH] Fix hdurl still being in API response when it doesn't exist. --- apod/utility.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/apod/utility.py b/apod/utility.py index 3d57eac..9e38cd9 100644 --- a/apod/utility.py +++ b/apod/utility.py @@ -113,7 +113,9 @@ def _get_apod_chars(dt, thumbs): props['date'] = _date(soup) if hd_data: - props['hdurl'] = _get_last_url(hd_data) + hdurl = _get_last_url(hd_data) + if requests.get(hdurl).status_code != 404: + props['hdurl'] = hdurl if thumbs and media_type == "video": if thumbs.lower() == "true":