Show upload ETA in appropriate time units
Signed-off-by: lzzy12 <jhashivam2020@gmail.com>
This commit is contained in:
parent
70eaada75f
commit
4fa2e71e98
|
|
@ -92,6 +92,22 @@ def get_readable_message(progress_list: list = None):
|
||||||
return msg
|
return msg
|
||||||
|
|
||||||
|
|
||||||
|
def get_readable_time(seconds: int) -> str:
|
||||||
|
result = ''
|
||||||
|
(days, remainder) = divmod(seconds, 86400)
|
||||||
|
if days != 0:
|
||||||
|
result += f'{days}d'
|
||||||
|
(hours, remainder) = divmod(remainder, 3600)
|
||||||
|
if hours != 0:
|
||||||
|
result += f'{hours}h'
|
||||||
|
(minutes, seconds) = divmod(remainder, 60)
|
||||||
|
if minutes != 0:
|
||||||
|
result += f'{minutes}m'
|
||||||
|
|
||||||
|
result += f'{seconds}s'
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
||||||
def is_url(url: str):
|
def is_url(url: str):
|
||||||
# TODO: Find the proper way to validate the url
|
# TODO: Find the proper way to validate the url
|
||||||
if url.startswith('https://') or url.startswith('http://'):
|
if url.startswith('https://') or url.startswith('http://'):
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
from bot import aria2, DOWNLOAD_DIR
|
from bot import aria2, DOWNLOAD_DIR
|
||||||
from bot.helper.ext_utils.bot_utils import get_readable_file_size, MirrorStatus
|
from bot.helper.ext_utils.bot_utils import get_readable_file_size, MirrorStatus, get_readable_time
|
||||||
|
|
||||||
|
|
||||||
def get_download(gid):
|
def get_download(gid):
|
||||||
|
|
@ -71,7 +71,8 @@ class DownloadStatus:
|
||||||
self.__update()
|
self.__update()
|
||||||
if self.status() == MirrorStatus.STATUS_UPLOADING:
|
if self.status() == MirrorStatus.STATUS_UPLOADING:
|
||||||
try:
|
try:
|
||||||
return f'{round((self.__size() - self.uploaded_bytes) / self.__upload_speed(), 2)} seconds'
|
seconds = round((self.__size() - self.uploaded_bytes) / self.__upload_speed(), 2)
|
||||||
|
return f'{get_readable_time(seconds)}'
|
||||||
except ZeroDivisionError:
|
except ZeroDivisionError:
|
||||||
return '-'
|
return '-'
|
||||||
return self.__download.eta_string()
|
return self.__download.eta_string()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue