summaryrefslogtreecommitdiff
path: root/tidal_dl_ng
diff options
context:
space:
mode:
authorRobert Honz <exislow+github@gmail.com>2025-02-28 13:22:38 +0100
committerRobert Honz <exislow+github@gmail.com>2025-02-28 13:22:38 +0100
commit56aff8fa19ef801c0582dbe37d2e689024303ed5 (patch)
tree2a3ebb34d973371b774c75476c313d2544ca4b93 /tidal_dl_ng
parentff96847e34b96a8f21bece8acaa5f4716c07091c (diff)
downloadtidal-dl-ng-56aff8fa19ef801c0582dbe37d2e689024303ed5.tar.gz
👷 Optimized CLI performance.
Diffstat (limited to 'tidal_dl_ng')
-rw-r--r--tidal_dl_ng/cli.py32
1 files changed, 19 insertions, 13 deletions
diff --git a/tidal_dl_ng/cli.py b/tidal_dl_ng/cli.py
index 54cbb5e..f99132e 100644
--- a/tidal_dl_ng/cli.py
+++ b/tidal_dl_ng/cli.py
@@ -62,6 +62,10 @@ def _download(ctx: typer.Context, urls: list[str], try_login: bool = True) -> bo
SpinnerColumn(),
BarColumn(),
TextColumn("[progress.percentage]{task.percentage:>3.0f}%"),
+ refresh_per_second=20,
+ auto_refresh=True,
+ expand=True,
+ transient=False, # Prevent progress from disappearing
)
fn_logger = LoggerWrapped(progress.print)
dl = Download(
@@ -78,21 +82,21 @@ def _download(ctx: typer.Context, urls: list[str], try_login: bool = True) -> bo
urls_pos_last = len(urls) - 1
- for item in urls:
- media_type: MediaType | bool = False
+ # Use a single Live display for both progress and table
+ with Live(progress_table, refresh_per_second=20):
+ for item in urls:
+ media_type: MediaType | bool = False
- # Extract media name and id from link.
- if "http" in item:
- media_type = get_tidal_media_type(item)
- item_id = get_tidal_media_id(item)
- file_template = get_format_template(media_type, settings)
- else:
- print(f"It seems like that you have supplied an invalid URL: {item}")
+ # Extract media name and id from link.
+ if "http" in item:
+ media_type = get_tidal_media_type(item)
+ item_id = get_tidal_media_id(item)
+ file_template = get_format_template(media_type, settings)
+ else:
+ print(f"It seems like that you have supplied an invalid URL: {item}")
- continue
+ continue
- # Create Live display for Progress.
- 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)
@@ -119,8 +123,10 @@ def _download(ctx: typer.Context, urls: list[str], try_login: bool = True) -> bo
download_delay=settings.data.download_delay,
)
- # Stop Progress display.
+ # Clear and stop progress display
+ progress.refresh()
progress.stop()
+ print("\nDownload completed!")
return True