summaryrefslogtreecommitdiff
path: root/tidal_dl_ng/download.py
diff options
context:
space:
mode:
authorexislow <exislow@users.noreply.github.com>2025-03-01 21:54:21 +0100
committerGitHub <noreply@github.com>2025-03-01 21:54:21 +0100
commit2aff7c920e9cddcd66df08e0e9299a9375c249d3 (patch)
treeb497073fce3ec20a990508a8386aa49ebe00d816 /tidal_dl_ng/download.py
parent326246cdcc7882e8224f5c30c17fe59b74a47bb3 (diff)
parent0726175503764477e83c16d7e43857c6fe257e71 (diff)
downloadtidal-dl-ng-2aff7c920e9cddcd66df08e0e9299a9375c249d3.tar.gz
Merge pull request #378 from exislow/374-remove-when-downloading-much-files
👷 CLI: Download list is scrolling vertically and overall progress is …
Diffstat (limited to 'tidal_dl_ng/download.py')
-rw-r--r--tidal_dl_ng/download.py17
1 files changed, 10 insertions, 7 deletions
diff --git a/tidal_dl_ng/download.py b/tidal_dl_ng/download.py
index 73305b0..c147ce9 100644
--- a/tidal_dl_ng/download.py
+++ b/tidal_dl_ng/download.py
@@ -73,6 +73,7 @@ class Download:
fn_logger: Callable
progress_gui: ProgressBars
progress: Progress
+ progress_overall: Progress
def __init__(
self,
@@ -82,6 +83,7 @@ class Download:
skip_existing: bool = False,
progress_gui: ProgressBars = None,
progress: Progress = None,
+ progress_overall: Progress = None,
):
self.settings = Settings()
self.session = session
@@ -89,6 +91,7 @@ class Download:
self.fn_logger = fn_logger
self.progress_gui = progress_gui
self.progress = progress
+ self.progress_overall = progress_overall
self.path_base = path_base
if not self.settings.data.path_binary_ffmpeg and (
@@ -150,8 +153,6 @@ class Download:
total_size_in_bytes: int = int(r.headers.get("content-length", 0))
block_size: int | None = 1048576
progress_total: float = total_size_in_bytes / block_size
- except:
- raise
finally:
r.close()
else:
@@ -709,10 +710,12 @@ class Download:
progress_stdout: bool = True
else:
progress_stdout: bool = False
- self.progress_gui.list_name.emit(list_media_name_short[:30])
+ self.progress_gui.list_name.emit(list_media_name_short)
+
+ progress: Progress = self.progress_overall if self.progress_overall else self.progress
# Create the list progress task.
- p_task1: TaskID = self.progress.add_task(
+ p_task1: TaskID = progress.add_task(
f"[green]List '{list_media_name_short}'", total=len(items), visible=progress_stdout
)
@@ -720,7 +723,7 @@ class Download:
result_dirs: [pathlib.Path] = []
# Iterate through list items
- while not self.progress.finished:
+ while not progress.finished:
with futures.ThreadPoolExecutor(max_workers=self.settings.data.downloads_concurrent_max) as executor:
# Dispatch all download tasks to worker threads
l_futures: [any] = [
@@ -744,10 +747,10 @@ class Download:
result_dirs.append(result_path_file.parent)
# Advance progress bar.
- self.progress.advance(p_task1)
+ progress.advance(p_task1)
if not progress_stdout:
- self.progress_gui.list_item.emit(self.progress.tasks[p_task1].percentage)
+ self.progress_gui.list_item.emit(progress.tasks[p_task1].percentage)
# Create playlist file
if self.settings.data.playlist_create: