Added direct testing fallback for getPreferredBitrate
This commit is contained in:
parent
b6eff13349
commit
2dab230a73
|
@ -59,6 +59,7 @@ class Deezer:
|
|||
for key, value in response.items():
|
||||
if key.startswith("FILESIZE_"):
|
||||
filesizes[key] = value
|
||||
filesizes[key+"_TESTED"] = False
|
||||
return filesizes
|
||||
|
||||
def gw_api_call(self, method, args=None):
|
||||
|
|
|
@ -506,6 +506,7 @@ class DownloadJob:
|
|||
logger.warn(f"[{track.mainArtist['name']} - {track.title}] Track not available in FLAC, falling back if necessary")
|
||||
self.removeTrackPercentage()
|
||||
track.filesizes['FILESIZE_FLAC'] = "0"
|
||||
track.filesizes['FILESIZE_FLAC_TESTED'] = True
|
||||
return self.download(trackAPI_gw, track)
|
||||
if track.searched:
|
||||
result['searched'] = f"{track.mainArtist['name']} - {track.title}"
|
||||
|
@ -546,9 +547,16 @@ class DownloadJob:
|
|||
|
||||
for format_num, format in formats.items():
|
||||
if format_num <= int(self.bitrate):
|
||||
if f"FILESIZE_{format}" in track.filesizes and int(track.filesizes[f"FILESIZE_{format}"]) != 0:
|
||||
if f"FILESIZE_{format}" in track.filesizes:
|
||||
if int(track.filesizes[f"FILESIZE_{format}"]) != 0:
|
||||
return format_num
|
||||
else:
|
||||
elif not track.filesizes[f"FILESIZE_{format}_TESTED"]:
|
||||
request = get(self.dz.get_track_stream_url(track.id, track.MD5, track.mediaVersion, format_num), stream=True)
|
||||
try:
|
||||
request.raise_for_status()
|
||||
return format_num
|
||||
except HTTPError: # if the format is not available, Deezer returns a 403 error
|
||||
pass
|
||||
if fallback:
|
||||
continue
|
||||
else:
|
||||
|
|
Loading…
Reference in New Issue