add basic auth support and few under the hood changes

This commit is contained in:
odysseusmax
2021-06-13 16:31:23 +05:30
parent 9eabc78872
commit 11f33611ae
13 changed files with 144 additions and 141 deletions

View File

@ -1,14 +1,19 @@
from urllib.parse import quote
def get_file_name(message):
if message.file.name:
return message.file.name.replace('\n', ' ')
ext = message.file.ext or ""
return f"{message.date.strftime('%Y-%m-%d_%H:%M:%S')}{ext}"
name = message.file.name
else:
ext = message.file.ext or ""
name = f"{message.date.strftime('%Y-%m-%d_%H:%M:%S')}{ext}"
return quote(name)
def get_human_size(num):
base = 1024.0
sufix_list = ['B','KiB','MiB','GiB','TiB','PiB','EiB','ZiB', 'YiB']
sufix_list = ["B", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB"]
for unit in sufix_list:
if abs(num) < base:
return f"{round(num, 2)} {unit}"
num /= base
num /= base