added multi-threaded downloading
This commit is contained in:
parent
61c2a337d7
commit
8a6afd969c
|
@ -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,10 +347,11 @@ 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)
|
||||||
|
|
Loading…
Reference in New Issue