videos: remove video uploads lol
This commit is contained in:
parent
0f10e1ea16
commit
872d9c613b
16 changed files with 30 additions and 136 deletions
|
@ -6,6 +6,7 @@ from files.helpers.alerts import *
|
|||
from files.helpers.comments import comment_filter_moderated
|
||||
from files.helpers.contentsorting import sort_objects
|
||||
from files.helpers.const import *
|
||||
from files.helpers.media import process_image
|
||||
from files.helpers.strings import sql_ilike_clean
|
||||
from files.classes import *
|
||||
from flask import *
|
||||
|
@ -320,22 +321,7 @@ def edit_post(pid, v):
|
|||
body += f"\n\n"
|
||||
else:
|
||||
body += f'\n\n<a href="{url}">{url}</a>'
|
||||
elif file.content_type.startswith('video/'):
|
||||
file.save("video.mp4")
|
||||
with open("video.mp4", 'rb') as f:
|
||||
try: req = requests.request("POST", "https://api.imgur.com/3/upload", headers={'Authorization': f'Client-ID {IMGUR_KEY}'}, files=[('video', f)], timeout=5).json()['data']
|
||||
except requests.Timeout: abort(500, "Video upload timed out, please try again!")
|
||||
try: url = req['link']
|
||||
except:
|
||||
error = req['error']
|
||||
if error == 'File exceeds max duration': error += ' (60 seconds)'
|
||||
abort(400, error)
|
||||
if url.endswith('.'): url += 'mp4'
|
||||
if app.config['MULTIMEDIA_EMBEDDING_ENABLED']:
|
||||
body += f"\n\n"
|
||||
else:
|
||||
body += f'\n\n<a href="{url}">{url}</a>'
|
||||
else: abort(400, "Image/Video files only")
|
||||
else: abort(400, "Image files only")
|
||||
|
||||
body_html = sanitize(body, edit=True)
|
||||
|
||||
|
@ -739,23 +725,8 @@ def submit_post(v, sub=None):
|
|||
body += f"\n\n"
|
||||
else:
|
||||
body += f'\n\n<a href="{image}">{image}</a>'
|
||||
elif file.content_type.startswith('video/'):
|
||||
file.save("video.mp4")
|
||||
with open("video.mp4", 'rb') as f:
|
||||
try: req = requests.request("POST", "https://api.imgur.com/3/upload", headers={'Authorization': f'Client-ID {IMGUR_KEY}'}, files=[('video', f)], timeout=5).json()['data']
|
||||
except requests.Timeout: return error("Video upload timed out, please try again!")
|
||||
try: url = req['link']
|
||||
except:
|
||||
err = req['error']
|
||||
if err == 'File exceeds max duration': err += ' (60 seconds)'
|
||||
return error(err)
|
||||
if url.endswith('.'): url += 'mp4'
|
||||
if app.config['MULTIMEDIA_EMBEDDING_ENABLED']:
|
||||
body += f"\n\n"
|
||||
else:
|
||||
body += f'\n\n<a href="{url}">{url}</a>'
|
||||
else:
|
||||
return error("Image/Video files only.")
|
||||
return error("Image files only")
|
||||
|
||||
body_html = sanitize(body)
|
||||
|
||||
|
@ -809,21 +780,9 @@ def submit_post(v, sub=None):
|
|||
|
||||
name2 = name.replace('.webp', 'r.webp')
|
||||
copyfile(name, name2)
|
||||
post.thumburl = process_image(name2, resize=100)
|
||||
elif file.content_type.startswith('video/'):
|
||||
file.save("video.mp4")
|
||||
with open("video.mp4", 'rb') as f:
|
||||
try: req = requests.request("POST", "https://api.imgur.com/3/upload", headers={'Authorization': f'Client-ID {IMGUR_KEY}'}, files=[('video', f)], timeout=5).json()['data']
|
||||
except requests.Timeout: return error("Video upload timed out, please try again!")
|
||||
try: url = req['link']
|
||||
except:
|
||||
err = req['error']
|
||||
if err == 'File exceeds max duration': err += ' (60 seconds)'
|
||||
return error(err)
|
||||
if url.endswith('.'): url += 'mp4'
|
||||
post.url = url
|
||||
post.thumburl = process_image(name2, resize=100)
|
||||
else:
|
||||
return error("Image/Video files only.")
|
||||
return error("Image files only")
|
||||
|
||||
if not post.thumburl and post.url:
|
||||
gevent.spawn(thumbnail_thread, post.id)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue