diff --git a/twitchdl/console.py b/twitchdl/console.py index 4e1dbb8..1244280 100644 --- a/twitchdl/console.py +++ b/twitchdl/console.py @@ -305,7 +305,7 @@ def main(): print_err(e) sys.exit(1) except KeyboardInterrupt: - print_err("Operation canceled") + print_err("\nOperation canceled") sys.exit(1) except GQLError as e: print_err(e) diff --git a/twitchdl/progress.py b/twitchdl/progress.py index a14ec64..c922efd 100644 --- a/twitchdl/progress.py +++ b/twitchdl/progress.py @@ -6,7 +6,7 @@ from statistics import mean from typing import Dict, Optional from twitchdl.output import print_out -from twitchdl.utils import format_size, format_duration +from twitchdl.utils import format_size, format_time logger = logging.getLogger(__name__) @@ -116,11 +116,10 @@ class Progress: progress = " ".join([ f"Downloaded {self.vod_downloaded_count}/{self.vod_count} VODs", - f"({self.progress_perc}%)", - f"{format_size(self.progress_bytes)}", - f"of ~{format_size(self.estimated_total)}" if self.estimated_total else "", - f"at {format_size(self.speed)}/s" if self.speed else "", - f"remaining ~{format_duration(self.remaining_time)}" if self.remaining_time is not None else "", + f"{self.progress_perc}%", + f"of ~{format_size(self.estimated_total)}" if self.estimated_total else "", + f"at {format_size(self.speed)}/s" if self.speed else "", + f"ETA {format_time(self.remaining_time)}" if self.remaining_time is not None else "", ]) print_out(f"\r{progress} ", end="") diff --git a/twitchdl/utils.py b/twitchdl/utils.py index cc823e6..d8dbe50 100644 --- a/twitchdl/utils.py +++ b/twitchdl/utils.py @@ -40,6 +40,19 @@ def format_duration(total_seconds): return "{} sec".format(seconds) +def format_time(total_seconds): + total_seconds = int(total_seconds) + hours = total_seconds // 3600 + remainder = total_seconds % 3600 + minutes = remainder // 60 + seconds = total_seconds % 60 + + if hours: + return f"{hours:02}:{minutes:02}:{seconds:02}" + + return f"{minutes:02}:{seconds:02}" + + def read_int(msg, min, max, default): msg = msg + " [default {}]: ".format(default)