feat: add /info command, pt. 3

Signed-off-by: mctaylors <cantsendmails@mctaylors.ru>
This commit is contained in:
Macintxsh 2025-05-18 13:12:57 +03:00
parent 270e1630d4
commit 1054299ed7
Signed by: mctaylors
GPG key ID: 4EEF4F949A266EE2
2 changed files with 18 additions and 3 deletions

View file

@ -11,6 +11,14 @@ def humanize_tags_from_json(value: str, default: str) -> str:
return default
def humanize_filesize(value: int) -> str:
for unit in ['B', 'KiB', 'MiB', 'GiB']:
if value < 1024 or unit == 'GiB':
break
value /= 1024
return f"{value:.2f} {unit}"
def format_rating(value: str) -> str | None:
match value:
case "g":
@ -48,6 +56,7 @@ def format_status(data) -> str:
status.append("Banned")
return " ".join(status)
def get_json(pathname: str) -> Any | None:
r = requests.get(f"http://{app.host}/{pathname}.json")