forked from MarseyWorld/MarseyWorld
master
parent
f4322680c1
commit
7677f0751f
|
@ -115,4 +115,8 @@ def upload_video(file):
|
||||||
finally:
|
finally:
|
||||||
remove(file_path)
|
remove(file_path)
|
||||||
|
|
||||||
return resp['link']
|
link = resp['link']
|
||||||
|
img = Image(text=link, deletehash=resp['deletehash'])
|
||||||
|
g.db.add(img)
|
||||||
|
|
||||||
|
return link
|
||||||
|
|
|
@ -538,23 +538,27 @@ def check_processing_thread(v, post, link, db):
|
||||||
headers = {"Authorization": f"Client-ID {IMGUR_KEY}"}
|
headers = {"Authorization": f"Client-ID {IMGUR_KEY}"}
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
time.sleep(15)
|
# break on error to prevent zombie threads
|
||||||
|
try:
|
||||||
|
time.sleep(15)
|
||||||
|
|
||||||
req = requests.get(f"https://api.imgur.com/3/image/{image_id}", headers=headers)
|
req = requests.get(f"https://api.imgur.com/3/image/{image_id}", headers=headers)
|
||||||
|
|
||||||
status = req.json()['data']['processing']['status']
|
status = req.json()['data']['processing']['status']
|
||||||
if status == 'completed':
|
if status == 'completed':
|
||||||
post.processing = False
|
post.processing = False
|
||||||
db.add(post)
|
db.add(post)
|
||||||
|
|
||||||
send_notification(
|
send_notification(
|
||||||
NOTIFICATIONS_ACCOUNT,
|
NOTIFICATIONS_ACCOUNT,
|
||||||
v,
|
v,
|
||||||
f"Your video has finished processing and your [post](/post/{post.id}) is now live.",
|
f"Your video has finished processing and your [post](/post/{post.id}) is now live.",
|
||||||
db=db
|
db=db
|
||||||
)
|
)
|
||||||
|
|
||||||
db.commit()
|
db.commit()
|
||||||
|
break
|
||||||
|
except Exception:
|
||||||
break
|
break
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue