added multi-threaded downloading

This commit is contained in:
uh_wot 2020-02-29 22:30:12 +01:00
parent 61c2a337d7
commit 8a6afd969c
1 changed files with 6 additions and 4 deletions

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,10 +347,11 @@ 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)