remotes/1693045480750635534/spooky-22
Aevann1 2022-03-22 05:45:32 +02:00
parent cb9087a0d9
commit 2c9dca2e8e
4 changed files with 13 additions and 7 deletions

2
env
View File

@ -10,7 +10,7 @@ export HCAPTCHA_SECRET="blahblahblah"
export YOUTUBE_KEY="blahblahblah"
export PUSHER_ID="blahblahblah"
export PUSHER_KEY="blahblahblah"
export IMGUR_KEY="45ec598cad8462c"
export IMGUR_KEY="blahblahblah"
export SPAM_SIMILARITY_THRESHOLD="0.5"
export SPAM_URL_SIMILARITY_THRESHOLD="0.1"
export SPAM_SIMILAR_COUNT_THRESHOLD="10"

View File

@ -324,7 +324,8 @@ def api_comment(v):
elif file.content_type.startswith('video/'):
file.save("video.mp4")
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']
except: return {"error": req['error']}, 400
if url.endswith('.'): url += 'mp4'
@ -804,7 +805,8 @@ def edit_comment(cid, v):
elif file.content_type.startswith('video/'):
file.save("video.mp4")
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']
except: return {"error": req['error']}, 400
if url.endswith('.'): url += 'mp4'

View File

@ -468,7 +468,8 @@ def edit_post(pid, v):
elif file.content_type.startswith('video/'):
file.save("video.mp4")
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']
except: return {"error": req['error']}, 400
if url.endswith('.'): url += 'mp4'
@ -1024,7 +1025,8 @@ def submit_post(v, sub=None):
elif file.content_type.startswith('video/'):
file.save("video.mp4")
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']
except: return {"error": req['error']}, 400
if url.endswith('.'): url += 'mp4'
@ -1130,7 +1132,8 @@ def submit_post(v, sub=None):
elif file.content_type.startswith('video/'):
file.save("video.mp4")
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']
except: return {"error": req['error']}, 400
if url.endswith('.'): url += 'mp4'

View File

@ -257,7 +257,8 @@ def settings_profile_post(v):
elif file.content_type.startswith('video/'):
file.save("video.mp4")
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']
except: return {"error": req['error']}, 400
if url.endswith('.'): url += 'mp4'