diff --git a/files/helpers/images.py b/files/helpers/images.py index 230a3637e..cf75b5105 100644 --- a/files/helpers/images.py +++ b/files/helpers/images.py @@ -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 \ No newline at end of file diff --git a/files/routes/posts.py b/files/routes/posts.py index 91d515f46..6d7cc9365 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -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)