Add max_connections for concurrent downloads

This commit is contained in:
nathom 2021-07-28 22:10:35 -07:00
parent aac254516f
commit 1e6c138e54
3 changed files with 13 additions and 3 deletions

View file

@ -3,10 +3,16 @@
folder = "" folder = ""
# Put Qobuz albums in a 'Qobuz' folder, Tidal albums in 'Tidal' etc. # Put Qobuz albums in a 'Qobuz' folder, Tidal albums in 'Tidal' etc.
source_subdirectories = false source_subdirectories = false
[downloads.concurrency]
# Download (and convert) tracks all at once, instead of sequentially. # Download (and convert) tracks all at once, instead of sequentially.
# If you are converting the tracks, or have fast internet, this will # If you are converting the tracks, or have fast internet, this will
# substantially improve processing speed. # substantially improve processing speed.
concurrent = false enabled = true
# The maximum number of tracks to download at once
# If you have very fast internet, you will benefit from a higher value,
# A value that is too high for your bandwidth may cause slowdowns
max_connections = 3
[qobuz] [qobuz]
# 1: 320kbps MP3, 2: 16/44.1, 3: 24/<=96, 4: 24/>=96 # 1: 320kbps MP3, 2: 16/44.1, 3: 24/<=96, 4: 24/>=96

View file

@ -218,6 +218,7 @@ class RipCore(list):
artwork, conversion, filepaths = tuple( artwork, conversion, filepaths = tuple(
session[key] for key in ("artwork", "conversion", "filepaths") session[key] for key in ("artwork", "conversion", "filepaths")
) )
concurrency = session["downloads"]["concurrency"]
return { return {
"parent_folder": session["downloads"]["folder"], "parent_folder": session["downloads"]["folder"],
"folder_format": filepaths["folder_format"], "folder_format": filepaths["folder_format"],
@ -228,7 +229,8 @@ class RipCore(list):
"set_playlist_to_album": session["metadata"]["set_playlist_to_album"], "set_playlist_to_album": session["metadata"]["set_playlist_to_album"],
"stay_temp": conversion["enabled"], "stay_temp": conversion["enabled"],
"conversion": conversion, "conversion": conversion,
"concurrent_downloads": session["downloads"]["concurrent"], "concurrent_downloads": concurrency["enabled"],
"max_connections": concurrency["max_connections"],
"new_tracknumbers": session["metadata"]["new_playlist_tracknumbers"], "new_tracknumbers": session["metadata"]["new_playlist_tracknumbers"],
"download_videos": session["tidal"]["download_videos"], "download_videos": session["tidal"]["download_videos"],
"download_booklets": session["qobuz"]["download_booklets"], "download_booklets": session["qobuz"]["download_booklets"],

View file

@ -1034,7 +1034,9 @@ class Tracklist(list):
# TODO: make this function return the items that have not been downloaded # TODO: make this function return the items that have not been downloaded
failed_downloads: List[Tuple[str, str, str]] = [] failed_downloads: List[Tuple[str, str, str]] = []
if kwargs.get("concurrent_downloads", True): if kwargs.get("concurrent_downloads", True):
with concurrent.futures.ThreadPoolExecutor(15) as executor: with concurrent.futures.ThreadPoolExecutor(
kwargs.get("max_connections", 3)
) as executor:
future_map = { future_map = {
executor.submit(target, item, **kwargs): item for item in self executor.submit(target, item, **kwargs): item for item in self
} }