mirror of
https://github.com/ihabunek/twitch-dl
synced 2024-08-30 18:32:25 +00:00
Use ansi escape code to clear line
This commit is contained in:
parent
3fe1faa18e
commit
38636e2b21
@ -1,4 +1,5 @@
|
||||
import json
|
||||
import sys
|
||||
from itertools import islice
|
||||
from typing import Any, Callable, Generator, List, Optional, TypeVar
|
||||
|
||||
@ -10,6 +11,11 @@ from twitchdl.twitch import Clip, Video
|
||||
T = TypeVar("T")
|
||||
|
||||
|
||||
def clear_line():
|
||||
sys.stdout.write("\033[1K")
|
||||
sys.stdout.write("\r")
|
||||
|
||||
|
||||
def truncate(string: str, length: int) -> str:
|
||||
if len(string) > length:
|
||||
return string[: length - 1] + "…"
|
||||
|
@ -7,7 +7,7 @@ from typing import Deque, Dict, NamedTuple, Optional
|
||||
|
||||
import click
|
||||
|
||||
from twitchdl.output import blue
|
||||
from twitchdl.output import blue, clear_line
|
||||
from twitchdl.utils import format_size, format_time
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
@ -127,7 +127,8 @@ class Progress:
|
||||
|
||||
self._recalculate()
|
||||
|
||||
click.echo(f"\rDownloaded {self.vod_downloaded_count}/{self.vod_count} VODs", nl=False)
|
||||
clear_line()
|
||||
click.echo(f"Downloaded {self.vod_downloaded_count}/{self.vod_count} VODs", nl=False)
|
||||
click.secho(f" {self.progress_perc}%", fg="blue", nl=False)
|
||||
|
||||
if self.estimated_total is not None:
|
||||
@ -141,6 +142,4 @@ class Progress:
|
||||
if self.remaining_time is not None:
|
||||
click.echo(f" ETA {blue(format_time(self.remaining_time))}", nl=False)
|
||||
|
||||
click.echo(" ", nl=False)
|
||||
|
||||
self.last_printed = now
|
||||
|
Loading…
Reference in New Issue
Block a user