mirror of
https://gitlab.com/octospacc/TelegramIndex-Fork.git
synced 2025-06-05 22:09:12 +02:00
add basic auth support and few under the hood changes
This commit is contained in:
15
app/util.py
15
app/util.py
@ -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
|
||||
|
Reference in New Issue
Block a user