Fix some random stuffs
Signed-off-by: lzzy12 <jhashivam2020@gmail.com>
This commit is contained in:
parent
6cc7f63410
commit
f83ab444d2
|
|
@ -1,9 +1,10 @@
|
||||||
import math
|
|
||||||
from bot import download_dict
|
from bot import download_dict
|
||||||
|
from bot.helper.download_status import DownloadStatus
|
||||||
|
|
||||||
PROGRESS_MAX_SIZE = math.floor(100 / 8)
|
PROGRESS_MAX_SIZE = 100 // 8
|
||||||
PROGRESS_INCOMPLETE = ['▏', '▎', '▍', '▌', '▋', '▊', '▉']
|
PROGRESS_INCOMPLETE = ['▏', '▎', '▍', '▌', '▋', '▊', '▉']
|
||||||
|
|
||||||
|
|
||||||
def get_download(message_id):
|
def get_download(message_id):
|
||||||
return download_dict[message_id].download()
|
return download_dict[message_id].download()
|
||||||
|
|
||||||
|
|
@ -12,25 +13,21 @@ def get_download_status_list():
|
||||||
return list(download_dict.values())
|
return list(download_dict.values())
|
||||||
|
|
||||||
|
|
||||||
def get_progress(status):
|
def get_progress_bar_string(status: DownloadStatus):
|
||||||
completed = status.download().completed_length/8
|
completed = status.download().completed_length/8
|
||||||
total = status.download().total_length/8
|
total = status.download().total_length/8
|
||||||
if total == 0:
|
if total == 0:
|
||||||
p = 0
|
p = 0
|
||||||
else:
|
else:
|
||||||
try:
|
|
||||||
p = round(completed * 100 / total)
|
p = round(completed * 100 / total)
|
||||||
except ZeroDivisionError:
|
|
||||||
pass
|
|
||||||
p = min(max(p, 0), 100)
|
p = min(max(p, 0), 100)
|
||||||
p_str = '['
|
cFull = p // 8
|
||||||
cFull = math.floor(p / 8)
|
|
||||||
cPart = p % 8 - 1
|
cPart = p % 8 - 1
|
||||||
p_str += '█'*cFull
|
p_str = '█'*cFull
|
||||||
if cPart >= 0:
|
if cPart >= 0:
|
||||||
p_str += PROGRESS_INCOMPLETE[cPart]
|
p_str += PROGRESS_INCOMPLETE[cPart]
|
||||||
p_str += ' '*(PROGRESS_MAX_SIZE - cFull)
|
p_str += ' '*(PROGRESS_MAX_SIZE - cFull)
|
||||||
p_str = f"{p_str}]"
|
p_str = f"[{p_str}]"
|
||||||
return p_str
|
return p_str
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -50,14 +47,16 @@ def get_download_str():
|
||||||
|
|
||||||
|
|
||||||
def get_readable_message(progress_list: list = download_dict.values()):
|
def get_readable_message(progress_list: list = download_dict.values()):
|
||||||
msg = ""
|
msg = ''
|
||||||
for status in progress_list:
|
for status in progress_list:
|
||||||
msg += f'<b>Name:</b> {status.name()}\n' \
|
msg += f'<b>Name:</b> {status.name()}\n' \
|
||||||
f'<b>status:</b> {status.status()}\n'
|
f'<b>status:</b> {status.status()}\n'
|
||||||
if status.status() == "Downloading":
|
|
||||||
msg += f'<code>{get_progress(status)}</code> {status.progress()} of {status.size()}\n' \
|
if status.status() == DownloadStatus.STATUS_DOWNLOADING:
|
||||||
f'<b>Speed:</b> {status.speed()}\n' \
|
msg += f'<code>{get_progress_bar_string(status)}</code> {status.progress()} of {status.size()}\n' \
|
||||||
f'<b>ETA:</b> {status.eta()}\n\n'
|
f'<b>Speed:</b> {status.speed()}\n' \
|
||||||
|
f'<b>ETA:</b> {status.eta()}\n'
|
||||||
|
msg += '\n'
|
||||||
return msg
|
return msg
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue