diff options
| author | exislow <exislow@users.noreply.github.com> | 2024-02-01 20:05:25 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-02-01 20:05:25 +0100 |
| commit | 9306a30f250b880ab092d27e08a809cd5f7ae7c7 (patch) | |
| tree | 082f5b16d7324986640bb3f0c68bdcf7fe969400 /tidal_dl_ng/download.py | |
| parent | 4b21ecd820159e7913eab62df83a3fc27bfafce6 (diff) | |
| parent | fe5d450cb3d3ae3514f11ec6685579b553ac6225 (diff) | |
| download | tidal-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.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) |
