burgers?
parent
89c27efd79
commit
0bd15d3914
|
@ -9,12 +9,12 @@ import time
|
|||
from .const import *
|
||||
|
||||
|
||||
def process_audio(patron, file):
|
||||
def process_audio(file):
|
||||
name = f'/audio/{time.time()}'.replace('.','') + '.mp3'
|
||||
file.save(name)
|
||||
|
||||
size = os.stat(name).st_size
|
||||
if size > 16 * 1024 * 1024 or not patron and size > 8 * 1024 * 1024:
|
||||
if size > 8 * 1024 * 1024:
|
||||
with open(name, 'rb') as f:
|
||||
os.remove(name)
|
||||
req = requests.request("POST", "https://pomf2.lain.la/upload.php", files={'files[]': f}, timeout=20).json()
|
||||
|
@ -27,19 +27,18 @@ def process_video(file):
|
|||
name = f'/videos/{time.time()}'.replace('.','')
|
||||
file.save(name)
|
||||
|
||||
spider = os.system(f'ffmpeg -y -loglevel warning -i {name} -map_metadata -1 -c:v copy -c:a copy {name}.mp4')
|
||||
|
||||
if spider: print(f'ffmpeg returned {spider}', flush=True)
|
||||
os.system(f'ffmpeg -y -loglevel warning -i {name} -map_metadata -1 -c:v copy -c:a copy {name}.mp4')
|
||||
os.remove(name)
|
||||
name += '.mp4'
|
||||
|
||||
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['description']}
|
||||
size = os.stat(name).st_size
|
||||
if size > 8 * 1024 * 1024:
|
||||
with open(name, 'rb') as f:
|
||||
os.remove(name)
|
||||
req = requests.request("POST", "https://pomf2.lain.la/upload.php", files={'files[]': f}, timeout=20).json()
|
||||
return req['files'][0]['url']
|
||||
|
||||
return f'{SITE_FULL}{name}'
|
||||
|
||||
|
||||
def process_image(patron, filename=None, resize=0):
|
||||
|
|
|
@ -313,7 +313,7 @@ def api_comment(v):
|
|||
if type(value) is str: body += f"\n\n{value}"
|
||||
else: return value
|
||||
elif file.content_type.startswith('audio/'):
|
||||
body += f"\n\n{process_audio(v.patron, file)}"
|
||||
body += f"\n\n{process_audio(file)}"
|
||||
else: return {"error": "Image/Video/Audio files only"}, 400
|
||||
|
||||
body = body.strip()
|
||||
|
@ -773,7 +773,7 @@ def edit_comment(cid, v):
|
|||
if type(value) is str: body += f"\n\n{value}"
|
||||
else: return value
|
||||
elif file.content_type.startswith('audio/'):
|
||||
body += f"\n\n{process_audio(v.patron, file)}"
|
||||
body += f"\n\n{process_audio(file)}"
|
||||
else: return {"error": "Image/Video/Audio files only"}, 400
|
||||
|
||||
body = body.strip()
|
||||
|
|
|
@ -468,7 +468,7 @@ def edit_post(pid, v):
|
|||
if type(value) is str: body += f"\n\n{value}"
|
||||
else: return value
|
||||
elif file.content_type.startswith('audio/'):
|
||||
body += f"\n\n{process_audio(v.patron, file)}"
|
||||
body += f"\n\n{process_audio(file)}"
|
||||
else: return {"error": "Image/Video/Audio files only"}, 400
|
||||
|
||||
body = body.strip()
|
||||
|
@ -1081,7 +1081,7 @@ def submit_post(v, sub=None):
|
|||
if type(value) is str: body += f"\n\n{value}"
|
||||
else: return error(value['error'])
|
||||
elif file.content_type.startswith('audio/'):
|
||||
body += f"\n\n{process_audio(v.patron, file)}"
|
||||
body += f"\n\n{process_audio(file)}"
|
||||
else:
|
||||
return error("Image/Video/Audio files only.")
|
||||
|
||||
|
@ -1186,7 +1186,7 @@ def submit_post(v, sub=None):
|
|||
if type(value) is str: post.url = value
|
||||
else: return error(value['error'])
|
||||
elif file.content_type.startswith('audio/'):
|
||||
post.url = process_audio(v.patron, file)
|
||||
post.url = process_audio(file)
|
||||
else:
|
||||
return error("Image/Video/Audio files only.")
|
||||
|
||||
|
|
|
@ -221,7 +221,7 @@ def settings_profile_post(v):
|
|||
if type(value) is str: bio += f"\n\n{value}"
|
||||
else: return value
|
||||
elif file.content_type.startswith('audio/'):
|
||||
bio += f"\n\n{process_audio(v.patron, file)}"
|
||||
bio += f"\n\n{process_audio(file)}"
|
||||
else:
|
||||
if request.headers.get("Authorization") or request.headers.get("xhr"): return {"error": "Image/Video/Audio files only"}, 400
|
||||
return render_template("settings_profile.html", v=v, error="Image/Video/Audio files only."), 400
|
||||
|
|
|
@ -408,7 +408,7 @@ def submit_contact(v):
|
|||
if type(value) is str: body_html += f"<p>{value}</p>"
|
||||
else: return value
|
||||
elif file.content_type.startswith('audio/'):
|
||||
body_html += f"<p>{process_audio(v.patron, file)}</p>"
|
||||
body_html += f"<p>{process_audio(file)}</p>"
|
||||
else: return {"error": "Image/Video/Audio files only"}, 400
|
||||
|
||||
|
||||
|
|
|
@ -705,7 +705,7 @@ def messagereply(v):
|
|||
if type(value) is str: body_html += f"<p>{value}</p>"
|
||||
else: return value
|
||||
elif file.content_type.startswith('audio/'):
|
||||
body_html += f"<p>{process_audio(v.patron, file)}</p>"
|
||||
body_html += f"<p>{process_audio(file)}</p>"
|
||||
else: return {"error": "Image/Video/Audio files only"}, 400
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue