From 92d24aca83322bd155691d9ef762b87dd1f0abf4 Mon Sep 17 00:00:00 2001 From: uh_wot <3631986-uh_wot@users.noreply.gitlab.com> Date: Sun, 1 Mar 2020 21:48:57 +0100 Subject: [PATCH 1/2] fixed HTTPError handling --- deemix/api/deezer.py | 1 + deemix/app/downloader.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/deemix/api/deezer.py b/deemix/api/deezer.py index 29f8d5a..efee77f 100755 --- a/deemix/api/deezer.py +++ b/deemix/api/deezer.py @@ -255,6 +255,7 @@ class Deezer: def stream_track(self, track_id, url, stream): request = requests.get(url, stream=True) + request.raise_for_status() blowfish_key = str.encode(self._get_blowfish_key(str(track_id))) i = 0 for chunk in request.iter_content(2048): diff --git a/deemix/app/downloader.py b/deemix/app/downloader.py index 2e3f9d7..984ce63 100644 --- a/deemix/app/downloader.py +++ b/deemix/app/downloader.py @@ -311,7 +311,7 @@ def downloadTrackObj(trackAPI, settings, overwriteBitrate=False, extraTrack=None with open(writepath, 'wb') as stream: dz.stream_track(track['id'], track['downloadUrl'], stream) except HTTPError: - remove(writePath) + remove(writepath) if track['selectedFormat'] == 9: print("Track not available in flac, trying mp3") track['filesize']['flac'] = 0 From ecc9b91d90eb54e948694661eb4b2576b8886968 Mon Sep 17 00:00:00 2001 From: uh_wot <3631986-uh_wot@users.noreply.gitlab.com> Date: Sun, 1 Mar 2020 21:50:53 +0100 Subject: [PATCH 2/2] fixed decrypt_track function --- deemix/api/deezer.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/deemix/api/deezer.py b/deemix/api/deezer.py index efee77f..e747e48 100755 --- a/deemix/api/deezer.py +++ b/deemix/api/deezer.py @@ -242,14 +242,13 @@ class Deezer: response = open(input, 'rb') outfile = open(output, 'wb') blowfish_key = str.encode(self._get_blowfish_key(str(track_id))) - blowfish = Blowfish.new(blowfish_key, Blowfish.MODE_CBC, b"\x00\x01\x02\x03\x04\x05\x06\x07") i = 0 while True: chunk = response.read(2048) if not chunk: break if (i % 3) == 0 and len(chunk) == 2048: - chunk = blowfish.decrypt(chunk) + chunk = Blowfish.new(blowfish_key, Blowfish.MODE_CBC, b"\x00\x01\x02\x03\x04\x05\x06\x07").decrypt(chunk) outfile.write(chunk) i += 1