From a161ba8f1c7bf04397af0a3025e8acbe0b1bbd1e Mon Sep 17 00:00:00 2001 From: RemixDev Date: Thu, 14 May 2020 12:27:07 +0200 Subject: [PATCH] Added image fallback to known working resoultion --- deemix/app/downloader.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/deemix/app/downloader.py b/deemix/app/downloader.py index fd3c9a3..56d6550 100644 --- a/deemix/app/downloader.py +++ b/deemix/app/downloader.py @@ -84,7 +84,15 @@ def downloadImage(url, path): sleep(1) return downloadImage(url, path) 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) return None else: