diff --git a/rip/config.toml b/rip/config.toml index cdf3389..4b0db84 100644 --- a/rip/config.toml +++ b/rip/config.toml @@ -136,6 +136,10 @@ source = "qobuz" # on this one. fallback_source = "deezer" +[theme] +# Options: "dainty" or "plain" +progress_bar = "dainty" + [misc] # Check whether a newer version of streamrip is available when starting up check_for_updates = true diff --git a/rip/core.py b/rip/core.py index 9d40475..fdcce4c 100644 --- a/rip/core.py +++ b/rip/core.py @@ -108,6 +108,9 @@ class RipCore(list): else: self.config = config + if (theme := self.config.file["theme"]["progress_bar"]) != TQDM_DEFAULT_THEME: + set_progress_bar_theme(theme.lower()) + def get_db(db_type: str) -> db.Database: db_settings = self.config.session["database"] db_class = db.CLASS_MAP[db_type] diff --git a/streamrip/utils.py b/streamrip/utils.py index 9d63ffc..a1afa74 100644 --- a/streamrip/utils.py +++ b/streamrip/utils.py @@ -500,13 +500,24 @@ def downsize_image(filepath: str, width: int, height: int): resized_image.save(filepath) -TQDM_BAR_FORMAT = ( - "{desc} |{bar}| (" - + click.style("{elapsed}", fg="magenta") - + " at " - + click.style("{rate_fmt}{postfix}", fg="cyan", bold=True) - + ")" -) +TQDM_THEMES = { + "plain": None, + "dainty": ( + "{desc} |{bar}| " + + click.style("{remaining}", fg="magenta") + + " left at " + + click.style("{rate_fmt}{postfix} ", fg="cyan", bold=True) + ), +} + +TQDM_DEFAULT_THEME = "dainty" + +TQDM_BAR_FORMAT = TQDM_THEMES["dainty"] + + +def set_progress_bar_theme(theme: str): + global TQDM_BAR_FORMAT + TQDM_BAR_FORMAT = TQDM_THEMES[theme] def tqdm_stream(iterator: DownloadStream, desc: Optional[str] = None) -> Generator: