summaryrefslogtreecommitdiff
path: root/tidal_dl_ng/download.py
diff options
context:
space:
mode:
authorexislow <exislow@users.noreply.github.com>2024-02-01 20:05:25 +0100
committerGitHub <noreply@github.com>2024-02-01 20:05:25 +0100
commit9306a30f250b880ab092d27e08a809cd5f7ae7c7 (patch)
tree082f5b16d7324986640bb3f0c68bdcf7fe969400 /tidal_dl_ng/download.py
parent4b21ecd820159e7913eab62df83a3fc27bfafce6 (diff)
parentfe5d450cb3d3ae3514f11ec6685579b553ac6225 (diff)
downloadtidal-dl-ng-9306a30f250b880ab092d27e08a809cd5f7ae7c7.tar.gz
Merge pull request #26 from exislow/dl-wait-track
✨ Respect download delay when downloading a bunch of tracks / videos.
Diffstat (limited to 'tidal_dl_ng/download.py')
-rw-r--r--tidal_dl_ng/download.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/tidal_dl_ng/download.py b/tidal_dl_ng/download.py
index 4d5b5e8..fb7db37 100644
--- a/tidal_dl_ng/download.py
+++ b/tidal_dl_ng/download.py
@@ -181,6 +181,7 @@ class Download:
media_id: str = None,
media_type: MediaType = None,
video_download: bool = True,
+ download_delay: bool = False,
) -> (bool, str):
# If no media instance is provided, we need to create the media instance.
if media_id and media_type:
@@ -241,6 +242,16 @@ class Download:
else:
self.fn_logger.debug(f"Download skipped, since file exists: '{path_file}'")
+ status_download: bool = not download_skip
+
+ # If a file was downloaded and the download delay is enabled, wait until the next download.
+ # Only use this, if you have a list of several Track items. Do not use this for list items.
+ if download_delay and status_download:
+ time_sleep: float = round(random.SystemRandom().uniform(2, 5), 1)
+
+ self.fn_logger.debug(f"Next download will start in {time_sleep} seconds.")
+ time.sleep(time_sleep)
+
return not download_skip, path_file
def cover_url(self, sid: str, dimension: CoverDimensions = CoverDimensions.Px320):
@@ -355,7 +366,6 @@ class Download:
if download_delay and status_download:
time_sleep: float = round(random.SystemRandom().uniform(2, 5), 1)
- # TODO: Fix logging. Is not displayed in debug window.
self.fn_logger.debug(f"Next download will start in {time_sleep} seconds.")
time.sleep(time_sleep)