forked from MarseyWorld/MarseyWorld
stop using lain.la
parent
3c261f19cd
commit
0c8ead2e7d
|
@ -39,11 +39,10 @@ def process_audio(file):
|
|||
|
||||
file.save(name)
|
||||
|
||||
if os.stat(name).st_size > 8 * 1024 * 1024:
|
||||
with open(name, 'rb') as f:
|
||||
size = os.stat(name).st_size
|
||||
if size > 16 * 1024 * 1024 or not g.v.patron and size > 8 * 1024 * 1024:
|
||||
os.remove(name)
|
||||
req = requests.post("https://pomf2.lain.la/upload.php", files={'files[]': f}, timeout=20).json()
|
||||
return req['files'][0]['url']
|
||||
abort(413)
|
||||
|
||||
return f'{SITE_FULL}{name}'
|
||||
|
||||
|
@ -52,6 +51,11 @@ def process_video(file):
|
|||
old = f'/videos/{time.time()}'.replace('.','')
|
||||
file.save(old)
|
||||
|
||||
size = os.stat(old).st_size
|
||||
if SITE_NAME != 'WPD' and (size > 32 * 1024 * 1024 or not g.v.patron and size > 64 * 1024 * 1024):
|
||||
os.remove(old)
|
||||
abort(414)
|
||||
|
||||
extension = file.filename.split('.')[-1].lower()
|
||||
if extension not in ['avi', 'mp4', 'webm', 'm4v', 'mov', 'mkv']:
|
||||
extension = 'mp4'
|
||||
|
@ -59,11 +63,6 @@ def process_video(file):
|
|||
|
||||
subprocess.run(["ffmpeg", "-y", "-loglevel", "warning", "-i", old, "-map_metadata", "-1", "-c:v", "copy", "-c:a", "copy", new], check=True)
|
||||
os.remove(old)
|
||||
if os.stat(new).st_size > 8 * 1024 * 1024:
|
||||
with open(new, 'rb') as f:
|
||||
os.remove(new)
|
||||
req = requests.post("https://pomf2.lain.la/upload.php", files={'files[]': f}, timeout=20).json()
|
||||
return req['files'][0]['url']
|
||||
return f'{SITE_FULL}{new}'
|
||||
|
||||
|
||||
|
@ -71,7 +70,7 @@ def process_video(file):
|
|||
def process_image(filename=None, resize=0, trim=False):
|
||||
size = os.stat(filename).st_size
|
||||
|
||||
if size > 16 * 1024 * 1024 or not patron and size > 8 * 1024 * 1024:
|
||||
if size > 16 * 1024 * 1024 or not g.v.patron and size > 8 * 1024 * 1024:
|
||||
os.remove(filename)
|
||||
abort(413)
|
||||
|
||||
|
|
|
@ -59,6 +59,12 @@ def error_413(e):
|
|||
return {"error": "Max image/audio size is 8 MB (16 MB for paypigs)"}, 413
|
||||
else: return render_template('errors/413.html', err=True), 413
|
||||
|
||||
@app.errorhandler(414)
|
||||
def error_414(e):
|
||||
if request.headers.get("Authorization") or request.headers.get("xhr"):
|
||||
return {"error": "Max video size is 32 MB (64 MB for paypigs)"}, 414
|
||||
else: return render_template('errors/414.html', err=True), 414
|
||||
|
||||
@app.errorhandler(415)
|
||||
def error_415(e):
|
||||
if request.headers.get("Authorization") or request.headers.get("xhr"): return {"error": "Please upload only Image, Video, or Audio files!"}, 415
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{% extends "default.html" %}
|
||||
|
||||
{% block title %}
|
||||
<title>Max file size is 8 MB (16 MB for paypigs)</title>
|
||||
<title>Max image/audio size is 8 MB (16 MB for paypigs)</title>
|
||||
{% endblock %}
|
||||
|
||||
{% block pagetype %}error-413{% endblock %}
|
||||
|
@ -12,7 +12,7 @@
|
|||
<div class="text-center px-3 my-8">
|
||||
<img alt=":#marseyretard:" loading="lazy" src="/e/marseychonker2.webp">
|
||||
<pre></pre>
|
||||
<h1 class="h5">Max file size is 8 MB (16 MB for paypigs)</h1>
|
||||
<h1 class="h5">Max image/audio size is 8 MB (16 MB for paypigs)</h1>
|
||||
<div><a href="/" class="btn btn-primary">Go to frontpage</a></div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
{% extends "default.html" %}
|
||||
|
||||
{% block title %}
|
||||
<title>Max video size is 32 MB (64 MB for paypigs)</title>
|
||||
{% endblock %}
|
||||
|
||||
{% block pagetype %}error-414{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-10 col-md-5">
|
||||
<div class="text-center px-3 my-8">
|
||||
<img alt=":#marseyretard:" loading="lazy" src="/e/marseychonker2.webp">
|
||||
<pre></pre>
|
||||
<h1 class="h5">Max video size is 32 MB (64 MB for paypigs)</h1>
|
||||
<div><a href="/" class="btn btn-primary">Go to frontpage</a></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
Loading…
Reference in New Issue