diff options
Diffstat (limited to 'tidal_dl_ng/download.py')
| -rw-r--r-- | tidal_dl_ng/download.py | 12 |
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) |
