Merge branch 'master' of uh_wot/deemix into master

This commit is contained in:
RemixDev 2020-02-29 21:34:41 +00:00 committed by Gogs
commit 486237131a
3 changed files with 20 additions and 15 deletions

View File

@ -2,7 +2,7 @@
import binascii
import hashlib
import blowfish
from Crypto.Cipher import Blowfish
import pyaes
import requests
@ -241,24 +241,26 @@ class Deezer:
def decrypt_track(self, track_id, input, output):
response = open(input, 'rb')
outfile = open(output, 'wb')
cipher = blowfish.Cipher(str.encode(self._get_blowfish_key(str(track_id))))
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 = b"".join(cipher.decrypt_cbc(chunk, b"\x00\x01\x02\x03\x04\x05\x06\x07"))
chunk = blowfish.decrypt(chunk)
outfile.write(chunk)
i += 1
def stream_track(self, track_id, url, stream):
request = requests.get(url, stream=True)
cipher = blowfish.Cipher(str.encode(self._get_blowfish_key(str(track_id))))
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
for chunk in request.iter_content(2048):
if (i % 3) == 0 and len(chunk) == 2048:
chunk = b"".join(cipher.decrypt_cbc(chunk, b"\x00\x01\x02\x03\x04\x05\x06\x07"))
chunk = blowfish.decrypt(chunk)
stream.write(chunk)
i += 1

View File

@ -7,6 +7,7 @@ from os import makedirs
from requests import get
from requests.exceptions import HTTPError
from tempfile import gettempdir
from concurrent.futures import ThreadPoolExecutor
dz = Deezer()
TEMPDIR = os.path.join(gettempdir(), 'deezloader-imgs')
@ -346,16 +347,18 @@ def download_album(id, settings, overwriteBitrate=False):
downloadTrackObj(trackAPI, settings, overwriteBitrate)
else:
tracksArray = dz.get_album_tracks_gw(id)
with ThreadPoolExecutor(settings['queueConcurrency']) as executor:
for trackAPI in tracksArray:
trackAPI['_EXTRA_ALBUM'] = albumAPI
trackAPI['FILENAME_TEMPLATE'] = settings['albumTracknameTemplate']
downloadTrackObj(trackAPI, settings, overwriteBitrate)
executor.submit(downloadTrackObj, trackAPI, settings, overwriteBitrate)
def download_playlist(id, settings, overwriteBitrate=False):
playlistAPI = dz.get_playlist(id)
playlistTracksAPI = dz.get_playlist_tracks_gw(id)
with ThreadPoolExecutor(settings['queueConcurrency']) as executor:
for pos, trackAPI in enumerate(playlistTracksAPI, start=1):
trackAPI['_EXTRA_PLAYLIST'] = playlistAPI
trackAPI['POSITION'] = pos
trackAPI['FILENAME_TEMPLATE'] = settings['playlistTracknameTemplate']
downloadTrackObj(trackAPI, settings, overwriteBitrate)
executor.submit(downloadTrackObj, trackAPI, settings, overwriteBitrate)

View File

@ -1,5 +1,5 @@
pyaes
blowfish
pycryptodome
mutagen
click
requests