From c8ce5847d4cb6d790cfb5c607a867a6e72adc6ca Mon Sep 17 00:00:00 2001 From: Nathan Thomas Date: Sun, 24 Dec 2023 10:52:27 -0800 Subject: [PATCH] Fix downloads when flac not available --- streamrip/client/deezer.py | 2 +- streamrip/client/downloadable.py | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/streamrip/client/deezer.py b/streamrip/client/deezer.py index 9cb1a68..e0f8535 100644 --- a/streamrip/client/deezer.py +++ b/streamrip/client/deezer.py @@ -153,7 +153,7 @@ class DeezerClient(Client): _, format_str = quality_map[quality] dl_info["quality_to_size"] = [ - track_info.get(f"FILESIZE_{format}", 0) for _, format in quality_map + int(track_info.get(f"FILESIZE_{format}", 0)) for _, format in quality_map ] token = track_info["TRACK_TOKEN"] diff --git a/streamrip/client/downloadable.py b/streamrip/client/downloadable.py index 43584d3..566c2fd 100644 --- a/streamrip/client/downloadable.py +++ b/streamrip/client/downloadable.py @@ -89,8 +89,11 @@ class DeezerDownloadable(Downloadable): logger.debug("Deezer info for downloadable: %s", info) self.session = session self.url = info["url"] - self.quality = info["quality"] - self._size = int(info["quality_to_size"][self.quality]) + max_quality_available = max( + i for i, size in enumerate(info["quality_to_size"]) if size > 0 + ) + self.quality = min(info["quality"], max_quality_available) + self._size = info["quality_to_size"][self.quality] if self.quality <= 1: self.extension = "mp3" else: