Skip to content

Commit

Permalink
refactor: use the same padding for download and scrape errors
Browse files Browse the repository at this point in the history
  • Loading branch information
NTFSvolume committed Jan 27, 2025
1 parent f1e12f7 commit 5778ff3
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions cyberdrop_dl/managers/progress_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,17 +113,21 @@ def print_stats(self, start_time: float) -> None:
log_green(f" Videos: {self.sort_progress.video_count:,}")
log_green(f" Other Files: {self.sort_progress.other_count:,}")

log_failures(self.scrape_stats_progress.return_totals(), "Scrape Failures:")
log_failures(self.download_stats_progress.return_totals(), "Download Failures:")
last_padding = log_failures(self.scrape_stats_progress.return_totals(), "Scrape Failures:")
log_failures(self.download_stats_progress.return_totals(), "Download Failures:", last_padding)


def log_failures(failures: list[UiFailureTotal], title: str = "Failures:") -> None:
def log_failures(failures: list[UiFailureTotal], title: str = "Failures:", last_padding: int = 0) -> int:
log_spacer(20, "")
log_cyan(title)
if not failures:
return log_green(" None")
log_green(" None")
return 0
error_padding = last_padding
error_codes = (f.error_code for f in failures if f.error_code is not None)
error_padding = len(str(max(error_codes)))
if error_codes:
error_padding = max(len(str(max(error_codes))), error_padding)
for f in failures:
error = f.error_code if f.error_code is not None else ""
log_red(f" {error:>{error_padding}} {f.msg}: {f.count:,}")
log_red(f" {error:>{error_padding}}{' ' if error_padding else ''}{f.msg}: {f.count:,}")
return error_padding

0 comments on commit 5778ff3

Please sign in to comment.