remotes/1693045480750635534/spooky-22
Aevann1 2021-10-01 08:29:04 +02:00
parent 90d15361a7
commit 03c02f156b
2 changed files with 8 additions and 17 deletions

View File

@ -37,19 +37,4 @@ def upload_ibb(file=None, resize=False):
with open("image.webp", 'rb') as f:
req = requests.post('https://catbox.moe/user/api.php', data={'userhash':CATBOX_KEY, 'reqtype':'fileupload'}, files={'fileToUpload':f})
return req.text
class UploadException(Exception):
"""Custom exception to raise if upload goes wrong"""
pass
def upload_video(file):
file.save("video.mp4")
with open("video.mp4", 'rb') as f:
req = requests.post('https://catbox.moe/user/api.php', data={'userhash':CATBOX_KEY, 'reqtype':'fileupload'}, files={'fileToUpload':f})
return req.text
return req.text

View File

@ -834,7 +834,13 @@ def submit_post(v):
), 403
if file.content_type.startswith('image/'): new_post.url = upload_ibb(file=file)
elif file.content_type.startswith('video/'): new_post.post_url = upload_video(file)
elif file.content_type.startswith('video/'):
file.save("video.mp4")
with open("video.mp4", 'rb') as f:
req = requests.post('https://catbox.moe/user/api.php', data={'userhash':CATBOX_KEY, 'reqtype':'fileupload'}, files={'fileToUpload':f})
print(req)
print(req.text)
new_post.post_url = req.text
g.db.add(new_post)