Skip to content

Commit 4e86374

Browse files
committed
Fix progressbar being too small
1 parent b63ae9c commit 4e86374

File tree

2 files changed

+17
-11
lines changed

2 files changed

+17
-11
lines changed

auto_editor/utils/bar.py

+16-10
Original file line numberDiff line numberDiff line change
@@ -89,20 +89,26 @@ def tick(self, index: float) -> None:
8989
percent = round(progress * 100, 1)
9090
p_pad = " " * (4 - len(str(percent)))
9191
columns = get_terminal_size().columns
92-
bar_len = max(1, columns - len_title - 32)
92+
bar_len = max(1, columns - len_title - 35)
9393
bar_str = self._bar_str(progress, bar_len)
9494

95-
bar = f" {self.icon}{title} {bar_str} {p_pad}{percent}% ETA {new_time}"
96-
97-
if len(bar) > columns - 2:
98-
bar = bar[: columns - 2]
99-
else:
100-
bar += " " * (columns - len(bar) - 4)
101-
102-
sys.stdout.write(bar + "\r")
95+
bar = f" {self.icon}{title} {bar_str} {p_pad}{percent}% ETA {new_time} \r"
96+
sys.stdout.write(bar)
10397

10498
def start(self, total: float, title: str = "Please wait") -> None:
105-
self.stack.append((title, len(title), total, time()))
99+
len_title = 0
100+
in_escape = False
101+
102+
for char in title:
103+
if not in_escape:
104+
if char == "\033":
105+
in_escape = True
106+
else:
107+
len_title += 1
108+
elif char == "m":
109+
in_escape = False
110+
111+
self.stack.append((title, len_title, total, time()))
106112

107113
try:
108114
self.tick(0)

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ authors = [{ name = "WyattBlue", email = "wyattblue@auto-editor.com" }]
1010
requires-python = ">=3.10,<3.14"
1111
dependencies = [
1212
"numpy>=1.24,<3.0",
13-
"pyav==14.2.0",
13+
"pyav==14.2.*",
1414
]
1515
keywords = [
1616
"video", "audio", "media", "editor", "editing",

0 commit comments

Comments
 (0)