👷 Optimized CLI performance.

This commit is contained in:
Robert Honz
2025-02-28 13:22:38 +01:00
parent ff96847e34
commit 56aff8fa19
+9 -3
View File
@@ -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,6 +82,8 @@ def _download(ctx: typer.Context, urls: list[str], try_login: bool = True) -> bo
urls_pos_last = len(urls) - 1
# 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
@@ -91,8 +97,6 @@ def _download(ctx: typer.Context, urls: list[str], try_login: bool = True) -> bo
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