From 5d68a32f608bc685ced614bb51523a331a07daa3 Mon Sep 17 00:00:00 2001 From: Luke Robles Date: Wed, 16 Sep 2020 11:37:28 -0700 Subject: [PATCH] add a .png if the image returns an imgur gallery --- app/get_from_reddit.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/get_from_reddit.py b/app/get_from_reddit.py index 4f9d8e66..636b05f9 100644 --- a/app/get_from_reddit.py +++ b/app/get_from_reddit.py @@ -45,5 +45,10 @@ def get_image(boards, nsfw=False): if response['data']['domain'] not in domains: # If we dont find an approved domain, re-try the request return get_image(boards, nsfw=nsfw) + image_url = response['data']['url'].replace('http://', 'https://') - return response['data']['url'].replace('http://', 'https://') + if not image_url.endswith('png') or not image_url.endswith('jpg') not image_url.endswith('gif'): + image_url = image_url + '.png' + + + return image_url