forked from rDrama/rDrama
master
parent
ce1e340f43
commit
4fabbc3423
|
@ -533,40 +533,40 @@ def filter_title(title):
|
|||
IMGUR_KEY = environ.get("IMGUR_KEY", "").strip()
|
||||
|
||||
|
||||
# def check_processing_thread(v, post, link, db):
|
||||
def check_processing_thread(v, post, link, db):
|
||||
|
||||
# image_id = link.split('/')[-1].rstrip('.mp4')
|
||||
# headers = {"Authorization": f"Client-ID {IMGUR_KEY}"}
|
||||
image_id = link.split('/')[-1].rstrip('.mp4')
|
||||
headers = {"Authorization": f"Client-ID {IMGUR_KEY}"}
|
||||
|
||||
# while True:
|
||||
# # break on error to prevent zombie threads
|
||||
# try:
|
||||
# time.sleep(15)
|
||||
while True:
|
||||
# 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']
|
||||
# if status == 'completed':
|
||||
# post.processing = False
|
||||
# db.add(post)
|
||||
status = req.json()['data']['processing']['status']
|
||||
if status == 'completed':
|
||||
post.processing = False
|
||||
db.add(post)
|
||||
|
||||
# send_notification(
|
||||
# NOTIFICATIONS_ACCOUNT,
|
||||
# v,
|
||||
# f"Your video has finished processing and your [post](/post/{post.id}) is now live.",
|
||||
# db=db
|
||||
# )
|
||||
send_notification(
|
||||
NOTIFICATIONS_ACCOUNT,
|
||||
v,
|
||||
f"Your video has finished processing and your [post](/post/{post.id}) is now live.",
|
||||
db=db
|
||||
)
|
||||
|
||||
# db.commit()
|
||||
# break
|
||||
# # just in case
|
||||
# elif status == 'failed':
|
||||
# print(f"video upload for post {post.id} failed")
|
||||
# break
|
||||
# except Exception as e:
|
||||
# traceback.print_exc()
|
||||
# print("retard. aborting thread")
|
||||
# break
|
||||
db.commit()
|
||||
break
|
||||
# just in case
|
||||
elif status == 'failed':
|
||||
print(f"video upload for post {post.id} failed")
|
||||
break
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
print("retard. aborting thread")
|
||||
break
|
||||
|
||||
|
||||
@app.post("/submit")
|
||||
|
|
Loading…
Reference in New Issue