fds
This commit is contained in:
parent
f6817240ae
commit
cbbde4c1b3
1 changed files with 2 additions and 1 deletions
|
@ -311,7 +311,8 @@ 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:
|
||||||
req = requests.request("POST", "https://api.imgur.com/3/upload", headers={'Authorization': f'Client-ID {IMGUR_KEY}'}, files=[('video', f)], timeout=5).json()['data']
|
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']
|
try: url = req['link']
|
||||||
except: return {"error": req['error']}, 400
|
except: return {"error": req['error']}, 400
|
||||||
if url.endswith('.'): url += 'mp4'
|
if url.endswith('.'): url += 'mp4'
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue