File size: 843 Bytes
e26cd2e
9be77c1
e26cd2e
 
 
 
 
9be77c1
 
 
 
e26cd2e
 
 
 
 
 
 
 
 
 
 
 
 
 
9be77c1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import json
import requests
from functools import lru_cache


@lru_cache
def load_codes_from_files() -> dict:
    url = "https://raw.githubusercontent.com/paveL1boyko/MuskEmpireBot/main/youtube.json"
    response = requests.get(url)
    response.raise_for_status()  # Ensure we got a valid response
    return response.json()


def num_prettier(num: int) -> str:
    number = abs(num)
    if number >= (comparer := 1e12):
        prettier_num = f"{number / comparer:.1f}T"
    elif number >= (comparer := 1e9):
        prettier_num = f"{number / comparer:.1f}B"
    elif number >= (comparer := 1e6):
        prettier_num = f"{number / comparer:.1f}M"
    elif number >= (comparer := 1e3):
        prettier_num = f"{number / comparer:.1f}k"
    else:
        prettier_num = str(number)
    return f"-{prettier_num}" if num < 0 else prettier_num