Added image fallback to known working resoultion

This commit is contained in:
RemixDev 2020-05-14 12:27:07 +02:00
parent 2c07d15397
commit a161ba8f1c
1 changed files with 9 additions and 1 deletions

View File

@ -84,7 +84,15 @@ def downloadImage(url, path):
sleep(1) sleep(1)
return downloadImage(url, path) return downloadImage(url, path)
except HTTPError: except HTTPError:
logger.warn("Couldn't download Image") if 'cdns-images.dzcdn.net' in url:
urlBase = url[:url.rfind("/")+1]
pictureUrl = url[len(urlBase):]
pictureSize = int(pictureUrl[:pictureUrl.find("x")])
if pictureSize > 1400:
logger.warn("Couldn't download "+str(pictureSize)+"x"+str(pictureSize)+" image, falling back to 1400x1400")
sleep(1)
return downloadImage(urlBase+pictureUrl.replace(str(pictureSize)+"x"+str(pictureSize), '1400x1400'), path)
logger.error("Couldn't download Image: "+url)
remove(path) remove(path)
return None return None
else: else: