dfssfd
This commit is contained in:
parent
5884d71a5c
commit
cf3459741a
2 changed files with 8 additions and 17 deletions
|
@ -38,18 +38,3 @@ def upload_ibb(file=None, resize=False):
|
|||
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
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue