forked from rDrama/rDrama
dfssfd
parent
90d15361a7
commit
03c02f156b
|
@ -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})
|
req = requests.post('https://catbox.moe/user/api.php', data={'userhash':CATBOX_KEY, 'reqtype':'fileupload'}, files={'fileToUpload':f})
|
||||||
|
|
||||||
return req.text
|
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
|
), 403
|
||||||
|
|
||||||
if file.content_type.startswith('image/'): new_post.url = upload_ibb(file=file)
|
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)
|
g.db.add(new_post)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue