From 112a2679cc365e0a01af204c9633dcfcbde11c43 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Sun, 22 May 2022 22:05:44 +0200 Subject: [PATCH] fsd --- files/helpers/media.py | 29 ++++++++++------------------- files/routes/front.py | 2 +- 2 files changed, 11 insertions(+), 20 deletions(-) diff --git a/files/helpers/media.py b/files/helpers/media.py index aa61082b6..7adbf993b 100644 --- a/files/helpers/media.py +++ b/files/helpers/media.py @@ -9,28 +9,19 @@ import time from .const import * def process_video(file): - original = f'/videos/{time.time()}'.replace('.','') - converted = f'{original}.mp4' - file.save(original) - ffmpreg_res = os.system(f'ffmpeg -y -loglevel warning -i {original} -map_metadata -1 {converted}') - os.remove(original) - if ffmpreg_res: - print(f'ffmpeg returned {ffmpreg_res}', flush=True) - # ffmpeg leaves a 0-sized output file usually but who knows what if it can be - # tricked into generating something very large? - try: os.remove(converted) - except: pass + name = f'/videos/{time.time()}'.replace('.','') + file.save(name) + os.system(f'ffmpeg -y -loglevel warning -i {name} -map_metadata -1 {name}.mp4') + os.remove(name) - return {"error": "Video conversion failed, choose a better video!"} - - with open(converted, 'rb') as f: - if SITE_NAME != 'rDrama' or os.stat(converted).st_size > 8 * 1024 * 1024: - os.remove(converted) + with open(f"{name}.mp4", 'rb') as f: + if SITE_NAME != 'rDrama' or os.stat(f'{name}.mp4').st_size > 8 * 1024 * 1024: + os.remove(f"{name}.mp4") 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: return req['files'][0]['url'] - except: return {"error": req.get('description', 'no description')} + except: return {"error": req['description']} def process_image(patron, filename=None, resize=0): @@ -60,4 +51,4 @@ def process_image(patron, filename=None, resize=0): i = ImageOps.exif_transpose(i) i.save(filename, format="WEBP", method=6) - return filename + return filename \ No newline at end of file diff --git a/files/routes/front.py b/files/routes/front.py index 93111f6ca..43b82221b 100644 --- a/files/routes/front.py +++ b/files/routes/front.py @@ -128,7 +128,7 @@ def notifications(v): for x in c.replies2: if x.replies2 == None: x.replies2 = [] count = 0 - while count < 10 and c.parent_comment and (c.parent_comment.author_id == v.id or c.parent_comment.id in cids): + while count < 50 and c.parent_comment and (c.parent_comment.author_id == v.id or c.parent_comment.id in cids): count += 1 c = c.parent_comment if c.replies2 == None: