From 1969d3ca7ebdc0afc3232df4c4c0eb9265284513 Mon Sep 17 00:00:00 2001 From: kermit Date: Tue, 29 Sep 2020 19:49:12 +0100 Subject: [PATCH] Use HEAD not GET to test track url, and send User-Agent Means we can avoid stream=True and the issues around returning the connection to the pool detailed here: https://requests.readthedocs.io/en/latest/user/advanced/#body-content-workflow --- deemix/app/downloadjob.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deemix/app/downloadjob.py b/deemix/app/downloadjob.py index eb3bed2..4d948c0 100644 --- a/deemix/app/downloadjob.py +++ b/deemix/app/downloadjob.py @@ -616,7 +616,7 @@ class DownloadJob: if int(track.filesizes[f"FILESIZE_{format}"]) != 0: return format_num 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) + request = requests.head(self.dz.get_track_stream_url(track.id, track.MD5, track.mediaVersion, format_num), headers={'User-Agent': USER_AGENT_HEADER}, timeout=30) try: request.raise_for_status() return format_num