From 10723940d1d776473be35fdaf7ba2af76f8af0e7 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Sun, 22 May 2022 18:19:49 +0200 Subject: [PATCH] sfd --- files/helpers/media.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/files/helpers/media.py b/files/helpers/media.py index b42f294ec..37ad14ca2 100644 --- a/files/helpers/media.py +++ b/files/helpers/media.py @@ -14,16 +14,15 @@ def process_video(file): os.system(f'ffmpeg -y -loglevel warning -i {name} -map_metadata -1 {name}.mp4') os.remove(name) - size = os.stat(f'{name}.mp4').st_size - with open(f"{name}.mp4", 'rb') as f: try: req = requests.request("POST", "https://pomf2.lain.la/upload.php", files={'files[]': f}, timeout=20).json() except requests.Timeout: return {"error": "Video upload timed out, please try again!"} - try: url = req['files'][0]['url'] - except: return {"error": req['description']} - return url - - if SITE_NAME != 'rDrama' or size > 8 * 1024 * 1024: os.remove(f"{name}.mp4") + + try: url = req['files'][0]['url'] + except: return {"error": req['description']} + if SITE_NAME != 'rDrama' or os.stat(f'{name}.mp4').st_size > 8 * 1024 * 1024: + os.remove(f"{name}.mp4") + return url def process_image(patron, filename=None, resize=0):