forked from MarseyWorld/MarseyWorld
fsd
parent
36e0ce6e0a
commit
112a2679cc
|
@ -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):
|
||||
|
|
|
@ -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:
|
||||
|
|
Loading…
Reference in New Issue