From c42eff7f95c19d48dcea6d389f93fadfb41b928a Mon Sep 17 00:00:00 2001 From: RemixDev Date: Sun, 13 Jun 2021 14:06:17 +0200 Subject: [PATCH] Fixed bitrate fallback check --- deemix/downloader.py | 3 ++- deemix/types/Track.py | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/deemix/downloader.py b/deemix/downloader.py index e2daa84..ea9659c 100644 --- a/deemix/downloader.py +++ b/deemix/downloader.py @@ -105,8 +105,9 @@ def getPreferredBitrate(track, bitrate, shouldFallback, uuid=None, listener=None ) try: request.raise_for_status() - track.filesizes[f"FILESIZE_{formatName}"] = request.headers["Content-Length"] + track.filesizes[f"FILESIZE_{formatName}"] = int(request.headers["Content-Length"]) track.filesizes[f"FILESIZE_{formatName}_TESTED"] = True + if track.filesizes[f"FILESIZE_{formatName}"] == 0: return None return formatNumber except requests.exceptions.HTTPError: # if the format is not available, Deezer returns a 403 error return None diff --git a/deemix/types/Track.py b/deemix/types/Track.py index 5014601..85e359e 100644 --- a/deemix/types/Track.py +++ b/deemix/types/Track.py @@ -92,7 +92,7 @@ class Track: filesizes = {} for key, value in response.items(): if key.startswith("FILESIZE_"): - filesizes[key] = value + filesizes[key] = int(value) filesizes[key+"_TESTED"] = False self.filesizes = filesizes