diff options
| author | Robert Honz <exislow+github@gmail.com> | 2024-02-01 20:04:55 +0100 |
|---|---|---|
| committer | Robert Honz <exislow+github@gmail.com> | 2024-02-01 20:04:55 +0100 |
| commit | fe5d450cb3d3ae3514f11ec6685579b553ac6225 (patch) | |
| tree | 082f5b16d7324986640bb3f0c68bdcf7fe969400 /tidal_dl_ng/cli.py | |
| parent | 4b21ecd820159e7913eab62df83a3fc27bfafce6 (diff) | |
| download | tidal-dl-ng-fe5d450cb3d3ae3514f11ec6685579b553ac6225.tar.gz | |
✨ Respect download delay when downloading a bunch of tracks / videos.
Diffstat (limited to 'tidal_dl_ng/cli.py')
| -rw-r--r-- | tidal_dl_ng/cli.py | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/tidal_dl_ng/cli.py b/tidal_dl_ng/cli.py index e84eafc..4902f74 100644 --- a/tidal_dl_ng/cli.py +++ b/tidal_dl_ng/cli.py @@ -105,7 +105,7 @@ def login(ctx: typer.Context) -> bool: def download( ctx: typer.Context, urls: Annotated[Optional[list[str]], typer.Argument()] = None, - list_urls: Annotated[ + file_urls: Annotated[ Optional[Path], typer.Option( "--list", @@ -122,8 +122,8 @@ def download( ): if not urls: # Read the text file provided. - if list_urls: - text = list_urls.read_text() + if file_urls: + text = file_urls.read_text() urls = text.splitlines() else: print("Provide either URLs, IDs or a file containing URLs (one per line).") @@ -154,6 +154,8 @@ def download( # Style Progress display. progress_table.add_row(Panel.fit(progress, title="Download Progress", border_style="green", padding=(2, 2))) + urls_pos_last = len(urls) - 1 + for item in urls: media_type: MediaType | bool = False @@ -173,10 +175,10 @@ def download( with Live(progress_table, refresh_per_second=10): # Download media. if media_type in [MediaType.TRACK, MediaType.VIDEO]: + download_delay: bool = bool(settings.data.download_delay and urls.index(item) < urls_pos_last) + dl.item( - media_id=item_id, - media_type=media_type, - file_template=file_template, + media_id=item_id, media_type=media_type, file_template=file_template, download_delay=download_delay ) elif media_type in [MediaType.ALBUM, MediaType.PLAYLIST, MediaType.MIX]: dl.items( |
