changed GET request in getPreferredBitrate to HEAD request

this prevents it from downloading the same track twice, should give a nice speed boost
This commit is contained in:
uh_wot 2020-05-13 15:53:36 +02:00
parent 91d0b63b58
commit 2199e4913c
1 changed files with 2 additions and 2 deletions

View File

@ -8,7 +8,7 @@ from tempfile import gettempdir
from time import sleep
from Cryptodome.Cipher import Blowfish
from requests import get
from requests import get, head
from requests.exceptions import HTTPError, ConnectionError
from deemix.api.deezer import APIError, USER_AGENT_HEADER
@ -120,7 +120,7 @@ def getPreferredBitrate(dz, track, bitrate, fallback=True):
for formatNum in formats:
if formatNum <= int(bitrate):
request = get(dz.get_track_stream_url(track['id'], track['MD5'], track['mediaVersion'], formatNum))
request = head(dz.get_track_stream_url(track['id'], track['MD5'], track['mediaVersion'], formatNum))
try:
request.raise_for_status()
except HTTPError: # if the format is not available, Deezer returns a 403 error