-
Notifications
You must be signed in to change notification settings - Fork 1
/
status.py
34 lines (32 loc) · 1.27 KB
/
status.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
def format_progress_bar(filename, percentage, done, total_size, status, eta, speed, elapsed, user_mention, user_id, aria2p_gid):
bar_length = 10
filled_length = int(bar_length * percentage / 100)
bar = '★' * filled_length + '☆' * (bar_length - filled_length)
def format_size(size):
size = int(size)
if size < 1024:
return f"{size} B"
elif size < 1024 ** 2:
return f"{size / 1024:.2f} KB"
elif size < 1024 ** 3:
return f"{size / 1024 ** 2:.2f} MB"
else:
return f"{size / 1024 ** 3:.2f} GB"
def format_time(seconds):
seconds = int(seconds)
if seconds < 60:
return f"{seconds} sec"
elif seconds < 3600:
return f"{seconds // 60} min"
else:
hours = seconds // 3600
minutes = (seconds % 3600) // 60
return f"{hours} hr {minutes} min"
return (
f"┏ ғɪʟᴇɴᴀᴍᴇ: {filename}\n"
f"┠ [{bar}] {percentage:.2f}%\n"
f"┠ ᴘʀᴏᴄᴇssᴇᴅ: {format_size(done)} ᴏғ {format_size(total_size)}\n"
f"┠ sᴛᴀᴛᴜs: {status}\n"
f"┠ sᴘᴇᴇᴅ: {format_size(speed)}/s\n"
f"┖ ᴜsᴇʀ: {user_mention} | ɪᴅ: {user_id}"
)