From ef0046f0910b7a96eef52cccb4bdd41416e76fd3 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Wed, 18 May 2022 21:29:07 +0200 Subject: [PATCH] fsd --- .gitignore | 2 +- files/routes/comments.py | 6 ++++-- files/routes/posts.py | 11 +++++++---- files/routes/settings.py | 3 ++- files/routes/static.py | 5 +++-- files/routes/users.py | 4 +++- 6 files changed, 20 insertions(+), 11 deletions(-) diff --git a/.gitignore b/.gitignore index 62ed1d6db..5b21b7455 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,6 @@ image.* video.mp4 -video.webm +unsanitized.mp4 cache/ __pycache__/ .idea/ diff --git a/files/routes/comments.py b/files/routes/comments.py index 82af05cf8..01548e980 100644 --- a/files/routes/comments.py +++ b/files/routes/comments.py @@ -311,7 +311,8 @@ def api_comment(v): return {"error": str(e)}, 400 body += f"\n\n![]({image})" elif file.content_type.startswith('video/'): - file.save("video.mp4") + file.save("unsanitized.mp4") + os.system(f'ffmpeg -y -loglevel warning -i unsanitized.mp4 -map_metadata -1 -c:v copy -c:a copy video.mp4') with open("video.mp4", 'rb') as f: try: req = requests.request("POST", "https://pomf2.lain.la/upload.php", files={'files[]': f}, timeout=5).json() except requests.Timeout: return {"error": "Video upload timed out, please try again!"} @@ -767,7 +768,8 @@ def edit_comment(cid, v): url = process_image(v.patron, name) body += f"\n\n![]({url})" elif file.content_type.startswith('video/'): - file.save("video.mp4") + file.save("unsanitized.mp4") + os.system(f'ffmpeg -y -loglevel warning -i unsanitized.mp4 -map_metadata -1 -c:v copy -c:a copy video.mp4') with open("video.mp4", 'rb') as f: try: req = requests.request("POST", "https://pomf2.lain.la/upload.php", files={'files[]': f}, timeout=5).json() except requests.Timeout: return {"error": "Video upload timed out, please try again!"} diff --git a/files/routes/posts.py b/files/routes/posts.py index 0c4166ad7..8d9821612 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -18,7 +18,7 @@ from os import path import requests from shutil import copyfile from sys import stdout - +import os if SITE_NAME == 'PCM': snappyquotes = [] else: snappyquotes = [f':#{x}:' for x in marseys_const2] @@ -464,7 +464,8 @@ def edit_post(pid, v): url = process_image(v.patron, name) body += f"\n\n![]({url})" elif file.content_type.startswith('video/'): - file.save("video.mp4") + file.save("unsanitized.mp4") + os.system(f'ffmpeg -y -loglevel warning -i unsanitized.mp4 -map_metadata -1 -c:v copy -c:a copy video.mp4') with open("video.mp4", 'rb') as f: try: req = requests.request("POST", "https://pomf2.lain.la/upload.php", files={'files[]': f}, timeout=5).json() except requests.Timeout: return {"error": "Video upload timed out, please try again!"} @@ -1077,7 +1078,8 @@ def submit_post(v, sub=None): file.save(name) body += f"\n\n![]({process_image(v.patron, name)})" elif file.content_type.startswith('video/'): - file.save("video.mp4") + file.save("unsanitized.mp4") + os.system(f'ffmpeg -y -loglevel warning -i unsanitized.mp4 -map_metadata -1 -c:v copy -c:a copy video.mp4') with open("video.mp4", 'rb') as f: try: req = requests.request("POST", "https://pomf2.lain.la/upload.php", files={'files[]': f}, timeout=5).json() except requests.Timeout: return {"error": "Video upload timed out, please try again!"} @@ -1182,7 +1184,8 @@ def submit_post(v, sub=None): copyfile(name, name2) post.thumburl = process_image(v.patron, name2, resize=100) elif file.content_type.startswith('video/'): - file.save("video.mp4") + file.save("unsanitized.mp4") + os.system(f'ffmpeg -y -loglevel warning -i unsanitized.mp4 -map_metadata -1 -c:v copy -c:a copy video.mp4') with open("video.mp4", 'rb') as f: try: req = requests.request("POST", "https://pomf2.lain.la/upload.php", files={'files[]': f}, timeout=5).json() except requests.Timeout: return {"error": "Video upload timed out, please try again!"} diff --git a/files/routes/settings.py b/files/routes/settings.py index 85c144c8e..8bc99dce6 100644 --- a/files/routes/settings.py +++ b/files/routes/settings.py @@ -217,7 +217,8 @@ def settings_profile_post(v): url = process_image(v.patron, name) bio += f"\n\n![]({url})" elif file.content_type.startswith('video/'): - file.save("video.mp4") + file.save("unsanitized.mp4") + os.system(f'ffmpeg -y -loglevel warning -i unsanitized.mp4 -map_metadata -1 -c:v copy -c:a copy video.mp4') with open("video.mp4", 'rb') as f: try: req = requests.request("POST", "https://pomf2.lain.la/upload.php", files={'files[]': f}, timeout=5).json() except requests.Timeout: return {"error": "Video upload timed out, please try again!"} diff --git a/files/routes/static.py b/files/routes/static.py index 32d9c51b2..8515201bd 100644 --- a/files/routes/static.py +++ b/files/routes/static.py @@ -4,7 +4,7 @@ from files.helpers.alerts import * from files.helpers.const import * from files.classes.award import AWARDS from sqlalchemy import func -from os import path +import os import calendar import matplotlib.pyplot as plt from files.classes.mod_logs import ACTIONTYPES, ACTIONTYPES2 @@ -404,7 +404,8 @@ def submit_contact(v): url = process_image(v.patron, name) body_html += f'' elif file.content_type.startswith('video/'): - file.save("video.mp4") + file.save("unsanitized.mp4") + os.system(f'ffmpeg -y -loglevel warning -i unsanitized.mp4 -map_metadata -1 -c:v copy -c:a copy video.mp4') with open("video.mp4", 'rb') as f: try: req = requests.request("POST", "https://pomf2.lain.la/upload.php", files={'files[]': f}, timeout=5).json() except requests.Timeout: return {"error": "Video upload timed out, please try again!"} diff --git a/files/routes/users.py b/files/routes/users.py index 15719901c..0072b35c7 100644 --- a/files/routes/users.py +++ b/files/routes/users.py @@ -13,6 +13,7 @@ from pusher_push_notifications import PushNotifications from collections import Counter import gevent from sys import stdout +import os if PUSHER_ID != 'blahblahblah': beams_client = PushNotifications(instance_id=PUSHER_ID, secret_key=PUSHER_KEY) @@ -700,7 +701,8 @@ def messagereply(v): url = process_image(v.patron, name) body_html += f'' elif file.content_type.startswith('video/'): - file.save("video.mp4") + file.save("unsanitized.mp4") + os.system(f'ffmpeg -y -loglevel warning -i unsanitized.mp4 -map_metadata -1 -c:v copy -c:a copy video.mp4') with open("video.mp4", 'rb') as f: try: req = requests.request("POST", "https://pomf2.lain.la/upload.php", files={'files[]': f}, timeout=5).json() except requests.exceptions.ConnectionError: return {"error": "Video upload timed out, please try again!"}