From 2199e4913ccb3fb7f97ab7ebfccac3e87f1390d2 Mon Sep 17 00:00:00 2001 From: uh_wot <3631986-uh_wot@users.noreply.gitlab.com> Date: Wed, 13 May 2020 15:53:36 +0200 Subject: [PATCH] changed GET request in getPreferredBitrate to HEAD request this prevents it from downloading the same track twice, should give a nice speed boost --- deemix/app/downloader.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/deemix/app/downloader.py b/deemix/app/downloader.py index 4045f07..0ec6d3c 100644 --- a/deemix/app/downloader.py +++ b/deemix/app/downloader.py @@ -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