master
Aevann1 2022-05-18 21:29:07 +02:00
parent 3354363261
commit ef0046f091
6 changed files with 20 additions and 11 deletions

2
.gitignore vendored
View File

@ -1,6 +1,6 @@
image.*
video.mp4
video.webm
unsanitized.mp4
cache/
__pycache__/
.idea/

View File

@ -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!"}

View File

@ -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!"}

View File

@ -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!"}

View File

@ -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'<img data-bs-target="#expandImageModal" data-bs-toggle="modal" onclick="expandDesktopImage(this.src)" class="img" src="{url}" loading="lazy">'
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!"}

View File

@ -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'<img data-bs-target="#expandImageModal" data-bs-toggle="modal" onclick="expandDesktopImage(this.src)" class="img" src="{url}" loading="lazy">'
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!"}