Spaces:
Running
Running
File size: 931 Bytes
66ca64a f02b1de 66ca64a f02b1de 66ca64a f02b1de 3926f24 f02b1de 66ca64a dc0c76c 7bf2558 8f9e879 367be45 66ca64a |
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 27 28 29 30 |
import os
import json
import random
import string
# Deleting audio
def deleteAudio(path: str, waitInSeconds: int = 0):
config = configFile()
os.system("rm {}/{}".format(config['static-path'], path))
# Config file reading
def configFile():
with open("/app/routes/config.json", "r") as file:
config = json.loads(file.read())
return config
# Hook for yt-dlp
def thisIsHook(d):
try:
if d['total_bytes'] > 52428800:
print("\nFILE IS BIG, ABORT!!!\n")
raise Exception(f"Too long file (recieved {d['total_bytes']/1048576}MB, max is 50MB)")
except: pass
# Get variable from request
def getFromRequest(request, thing: str):
return request.json.get(thing) if request.is_json else request.form.get(thing)
def randString(len: int = 16):
return ''.join(random.SystemRandom().choice(string.ascii_uppercase + string.ascii_lowercase + string.digits) for _ in range(len)) |