Better download managing for covers

This commit is contained in:
RemixDev 2020-09-10 11:43:32 +02:00
parent 37b801f2f0
commit da34c289a7
3 changed files with 9 additions and 7 deletions

View File

@ -1,3 +1,3 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
__version__ = "1.2.19" __version__ = "1.2.20"

View File

@ -66,10 +66,13 @@ def downloadImage(url, path, overwrite="n"):
logger.warn("Couldn't download "+str(pictureSize)+"x"+str(pictureSize)+" image, falling back to 1200x1200") logger.warn("Couldn't download "+str(pictureSize)+"x"+str(pictureSize)+" image, falling back to 1200x1200")
sleep(1) sleep(1)
return downloadImage(urlBase+pictureUrl.replace(str(pictureSize)+"x"+str(pictureSize), '1200x1200'), path, overwrite) return downloadImage(urlBase+pictureUrl.replace(str(pictureSize)+"x"+str(pictureSize), '1200x1200'), path, overwrite)
logger.error("Couldn't download Image: "+url) logger.error("Image not found: "+url)
except: except (request_exception.ConnectionError, request_exception.ChunkedEncodingError) as e:
sleep(1) logger.error("Couldn't download Image, retrying in 5 seconds...: "url+"\n")
sleep(5)
return downloadImage(url, path, overwrite) return downloadImage(url, path, overwrite)
except Exception as e:
logger.exception(f"Error while downloading an image, you should report this to the developers: {str(e)}")
if os.path.isfile(path): remove(path) if os.path.isfile(path): remove(path)
return None return None
else: else:
@ -480,8 +483,7 @@ class DownloadJob:
return downloadMusic(track, trackAPI_gw) return downloadMusic(track, trackAPI_gw)
except Exception as e: except Exception as e:
remove(writepath) remove(writepath)
logger.exception(str(e)) logger.exception(f"[{track.mainArtist['name']} - {track.title}] Error while downloading the track, you should report this to the developers: {str(e)}")
logger.warn(f"[{track.mainArtist['name']} - {track.title}] Error while downloading the track, you should report this to the developers")
raise e raise e
return True return True

View File

@ -7,7 +7,7 @@ README = (HERE / "README.md").read_text()
setup( setup(
name="deemix", name="deemix",
version="1.2.19", version="1.2.20",
description="A barebone deezer downloader library", description="A barebone deezer downloader library",
long_description=README, long_description=README,
long_description_content_type="text/markdown", long_description_content_type="text/markdown",