master
Aevann1 2021-12-18 06:48:10 +02:00
parent e37c96c85e
commit 72405e77f3
3 changed files with 10 additions and 10 deletions

View File

@ -196,14 +196,14 @@ def api_comment(v):
name = f'/images/{time.time()}'.replace('.','')[:-5] + '.webp'
file.save(name)
url = process_image(name)
body += f"\n\n![]({url})"
elif file.content_type.startswith('video/'):
file.save("video.mp4")
with open("video.mp4", 'rb') as f:
url = requests.request("POST", "https://api.imgur.com/3/upload", headers={'Authorization': f'Client-ID {CATBOX_KEY}'}, files=[('video', f)]).json()['data']['link']
body += f"\n\n{url}"
else: return {"error": f"Image/Video files only"}, 400
body += f"\n\n{url}"
if v.agendaposter and not v.marseyawarded:
for k, l in AJ_REPLACEMENTS.items(): body = body.replace(k, l)
body = body.replace('I ', f'@{v.username} ')
@ -730,13 +730,14 @@ def edit_comment(cid, v):
name = f'/images/{time.time()}'.replace('.','')[:-5] + '.webp'
file.save(name)
url = process_image(name)
body += f"\n\n![]({url})"
elif file.content_type.startswith('video/'):
file.save("video.mp4")
with open("video.mp4", 'rb') as f:
url = requests.request("POST", "https://api.imgur.com/3/upload", headers={'Authorization': f'Client-ID {CATBOX_KEY}'}, files=[('video', f)]).json()['data']['link']
body += f"\n\n{url}"
else: return {"error": f"Image/Video files only"}, 400
body += f"\n\n{url}"
body_md = CustomRenderer().render(mistletoe.Document(body))
body_html = sanitize(body_md)

View File

@ -425,14 +425,14 @@ def edit_post(pid, v):
name = f'/images/{time.time()}'.replace('.','')[:-5] + '.webp'
file.save(name)
url = process_image(name)
body += f"\n\n![]({url})"
elif file.content_type.startswith('video/'):
file.save("video.mp4")
with open("video.mp4", 'rb') as f:
url = requests.request("POST", "https://api.imgur.com/3/upload", headers={'Authorization': f'Client-ID {CATBOX_KEY}'}, files=[('video', f)]).json()['data']['link']
body += f"\n\n{url}"
else: return {"error": f"Image/Video files only"}, 400
body += f"\n\n{url}"
if body != p.body:
for i in re.finditer('^(https:\/\/.*\.(png|jpg|jpeg|gif|webp|PNG|JPG|JPEG|GIF|WEBP|9999))', body, re.MULTILINE):
if "wikipedia" not in i.group(1): body = body.replace(i.group(1), f'![]({i.group(1)})')
@ -924,17 +924,16 @@ def submit_post(v):
if file.content_type.startswith('image/'):
name = f'/images/{time.time()}'.replace('.','')[:-5] + '.webp'
file.save(name)
url = process_image(name)
body += f"\n\n![]({url})"
elif file.content_type.startswith('video/'):
file.save("video.mp4")
with open("video.mp4", 'rb') as f:
url = requests.request("POST", "https://api.imgur.com/3/upload", headers={'Authorization': f'Client-ID {CATBOX_KEY}'}, files=[('video', f)]).json()['data']['link']
body += f"\n\n{url}"
else:
if request.headers.get("Authorization"): return {"error": f"Image/Video files only"}, 400
else: return render_template("submit.html", v=v, error=f"Image/Video files only."), 400
body += f"\n\n{url}"
body_html = sanitize(CustomRenderer().render(mistletoe.Document(body)))
if v.marseyawarded and len(list(re.finditer('>[^<\s+]|[^>\s+]<', body_html))) > 0: return {"error":"You can only type marseys!"}, 400

View File

@ -275,15 +275,15 @@ def settings_profile_post(v):
name = f'/images/{time.time()}'.replace('.','')[:-5] + '.webp'
file.save(name)
url = process_image(name)
bio += f"\n\n![]({url})"
elif file.content_type.startswith('video/'):
file.save("video.mp4")
with open("video.mp4", 'rb') as f:
url = requests.request("POST", "https://api.imgur.com/3/upload", headers={'Authorization': f'Client-ID {CATBOX_KEY}'}, files=[('video', f)]).json()['data']['link']
bio += f"\n\n{url}"
else:
if request.headers.get("Authorization"): return {"error": f"Image/Video files only"}, 400
else: return render_template("settings_profile.html", v=v, error=f"Image/Video files only."), 400
bio += f"\n\n{url}"
bio_html = CustomRenderer().render(mistletoe.Document(bio))
bio_html = sanitize(bio_html)