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 binascii
import hashlib import hashlib
import blowfish from Crypto.Cipher import Blowfish
import pyaes import pyaes
import requests import requests
@ -241,24 +241,26 @@ class Deezer:
def decrypt_track(self, track_id, input, output): def decrypt_track(self, track_id, input, output):
response = open(input, 'rb') response = open(input, 'rb')
outfile = open(output, 'wb') 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 i = 0
while True: while True:
chunk = response.read(2048) chunk = response.read(2048)
if not chunk: if not chunk:
break break
if (i % 3) == 0 and len(chunk) == 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)
outfile.write(chunk) outfile.write(chunk)
i += 1 i += 1
def stream_track(self, track_id, url, stream): def stream_track(self, track_id, url, stream):
request = requests.get(url, stream=True) 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 i = 0
for chunk in request.iter_content(2048): for chunk in request.iter_content(2048):
if (i % 3) == 0 and len(chunk) == 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) stream.write(chunk)
i += 1 i += 1

View File

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

View File

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