cmon
This commit is contained in:
parent
37adeb235f
commit
572b8f34cf
4 changed files with 21 additions and 14 deletions
|
@ -323,8 +323,9 @@ def api_comment(v):
|
||||||
elif file.content_type.startswith('video/'):
|
elif file.content_type.startswith('video/'):
|
||||||
file.save("video.mp4")
|
file.save("video.mp4")
|
||||||
with open("video.mp4", 'rb') as f:
|
with open("video.mp4", 'rb') as f:
|
||||||
try: url = requests.request("POST", "https://api.imgur.com/3/upload", headers={'Authorization': f'Client-ID {IMGUR_KEY}'}, files=[('video', f)], timeout=5).json()['data']['link']
|
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: return {"error": "Imgur error"}, 400
|
try: url = req['link']
|
||||||
|
except: return {"error": req['error']}, 400
|
||||||
if url.endswith('.'): url += 'mp4'
|
if url.endswith('.'): url += 'mp4'
|
||||||
body += f"\n\n{url}"
|
body += f"\n\n{url}"
|
||||||
else: return {"error": "Image/Video files only"}, 400
|
else: return {"error": "Image/Video files only"}, 400
|
||||||
|
@ -802,8 +803,9 @@ def edit_comment(cid, v):
|
||||||
elif file.content_type.startswith('video/'):
|
elif file.content_type.startswith('video/'):
|
||||||
file.save("video.mp4")
|
file.save("video.mp4")
|
||||||
with open("video.mp4", 'rb') as f:
|
with open("video.mp4", 'rb') as f:
|
||||||
try: url = requests.request("POST", "https://api.imgur.com/3/upload", headers={'Authorization': f'Client-ID {IMGUR_KEY}'}, files=[('video', f)], timeout=5).json()['data']['link']
|
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: return {"error": "Imgur error"}, 400
|
try: url = req['link']
|
||||||
|
except: return {"error": req['error']}, 400
|
||||||
if url.endswith('.'): url += 'mp4'
|
if url.endswith('.'): url += 'mp4'
|
||||||
body += f"\n\n{url}"
|
body += f"\n\n{url}"
|
||||||
else: return {"error": "Image/Video files only"}, 400
|
else: return {"error": "Image/Video files only"}, 400
|
||||||
|
|
|
@ -468,8 +468,9 @@ def edit_post(pid, v):
|
||||||
elif file.content_type.startswith('video/'):
|
elif file.content_type.startswith('video/'):
|
||||||
file.save("video.mp4")
|
file.save("video.mp4")
|
||||||
with open("video.mp4", 'rb') as f:
|
with open("video.mp4", 'rb') as f:
|
||||||
try: url = requests.request("POST", "https://api.imgur.com/3/upload", headers={'Authorization': f'Client-ID {IMGUR_KEY}'}, files=[('video', f)], timeout=5).json()['data']['link']
|
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: return {"error": "Imgur error"}, 400
|
try: url = req['link']
|
||||||
|
except: return {"error": req['error']}, 400
|
||||||
if url.endswith('.'): url += 'mp4'
|
if url.endswith('.'): url += 'mp4'
|
||||||
body += f"\n\n{url}"
|
body += f"\n\n{url}"
|
||||||
else: return {"error": "Image/Video files only"}, 400
|
else: return {"error": "Image/Video files only"}, 400
|
||||||
|
@ -1017,8 +1018,9 @@ def submit_post(v, sub=None):
|
||||||
elif file.content_type.startswith('video/'):
|
elif file.content_type.startswith('video/'):
|
||||||
file.save("video.mp4")
|
file.save("video.mp4")
|
||||||
with open("video.mp4", 'rb') as f:
|
with open("video.mp4", 'rb') as f:
|
||||||
try: url = requests.request("POST", "https://api.imgur.com/3/upload", headers={'Authorization': f'Client-ID {IMGUR_KEY}'}, files=[('video', f)], timeout=5).json()['data']['link']
|
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: return error( "Imgur error")
|
try: url = req['link']
|
||||||
|
except: return {"error": req['error']}, 400
|
||||||
if url.endswith('.'): url += 'mp4'
|
if url.endswith('.'): url += 'mp4'
|
||||||
body += f"\n\n{url}"
|
body += f"\n\n{url}"
|
||||||
else:
|
else:
|
||||||
|
@ -1122,8 +1124,9 @@ def submit_post(v, sub=None):
|
||||||
elif file.content_type.startswith('video/'):
|
elif file.content_type.startswith('video/'):
|
||||||
file.save("video.mp4")
|
file.save("video.mp4")
|
||||||
with open("video.mp4", 'rb') as f:
|
with open("video.mp4", 'rb') as f:
|
||||||
try: url = requests.request("POST", "https://api.imgur.com/3/upload", headers={'Authorization': f'Client-ID {IMGUR_KEY}'}, files=[('video', f)], timeout=5).json()['data']['link']
|
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: return error( "Imgur error")
|
try: url = req['link']
|
||||||
|
except: return {"error": req['error']}, 400
|
||||||
if url.endswith('.'): url += 'mp4'
|
if url.endswith('.'): url += 'mp4'
|
||||||
post.url = url
|
post.url = url
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -257,8 +257,9 @@ def settings_profile_post(v):
|
||||||
elif file.content_type.startswith('video/'):
|
elif file.content_type.startswith('video/'):
|
||||||
file.save("video.mp4")
|
file.save("video.mp4")
|
||||||
with open("video.mp4", 'rb') as f:
|
with open("video.mp4", 'rb') as f:
|
||||||
try: url = requests.request("POST", "https://api.imgur.com/3/upload", headers={'Authorization': f'Client-ID {IMGUR_KEY}'}, files=[('video', f)], timeout=5).json()['data']['link']
|
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: return {"error": "Imgur error"}, 400
|
try: url = req['link']
|
||||||
|
except: return {"error": req['error']}, 400
|
||||||
if url.endswith('.'): url += 'mp4'
|
if url.endswith('.'): url += 'mp4'
|
||||||
bio += f"\n\n{url}"
|
bio += f"\n\n{url}"
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -305,8 +305,9 @@ def submit_contact(v):
|
||||||
elif file.content_type.startswith('video/'):
|
elif file.content_type.startswith('video/'):
|
||||||
file.save("video.mp4")
|
file.save("video.mp4")
|
||||||
with open("video.mp4", 'rb') as f:
|
with open("video.mp4", 'rb') as f:
|
||||||
try: url = requests.request("POST", "https://api.imgur.com/3/upload", headers={'Authorization': f'Client-ID {IMGUR_KEY}'}, files=[('video', f)], timeout=5).json()['data']['link']
|
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: return {"error": "Imgur error"}, 400
|
try: url = req['link']
|
||||||
|
except: return {"error": req['error']}, 400
|
||||||
if url.endswith('.'): url += 'mp4'
|
if url.endswith('.'): url += 'mp4'
|
||||||
body_html += f"<p>{url}</p>"
|
body_html += f"<p>{url}</p>"
|
||||||
else: return {"error": "Image/Video files only"}, 400
|
else: return {"error": "Image/Video files only"}, 400
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue