Browse Source

Merge branch 'master' of http://git.choozmo.com:3000/ming/AI_Anchor

huaisianhuang 3 years ago
parent
commit
d2e50f5860
1 changed files with 8 additions and 5 deletions
  1. 8 5
      api/main.py

+ 8 - 5
api/main.py

@@ -38,6 +38,8 @@ import pymysql
 from first import first
 import mailer
 from moviepy.editor import VideoFileClip
+import traceback
+import logging
 pymysql.install_as_MySQLdb()
 
 app = FastAPI()
@@ -426,8 +428,8 @@ def gen_video_queue(name_hash,name,text_content, image_urls,avatar,user_id):
             print('all finish, leave loop')
             break
         top1 = first(db.query('SELECT * FROM video_queue'))
-        #try:
-        if True:
+        try:
+        # if True:
             db.query('UPDATE video_queue_status SET status = 1;')
             c = rpyc.connect("localhost", 8858)
             c._config['sync_request_timeout'] = None
@@ -454,9 +456,10 @@ def gen_video_queue(name_hash,name,text_content, image_urls,avatar,user_id):
                 db.query('UPDATE users SET left_time ='+str(left_time)+' WHERE id='+str(user_id)+';')
                 notify_group(name+"的影片已經產生完成囉! www.choozmo.com:8168/"+video_sub_folder+name_hash+".mp4")
                 notify_line_user(name+"的影片已經產生完成囉! www.choozmo.com:8168/"+video_sub_folder+name_hash+".mp4", line_token)
-        #except:
-            #print('video generation error')
-            #notify_group('影片錯誤')
+        except Exception as e:
+            logging.error(traceback.format_exc())
+            print('video generation error')
+            notify_group('影片錯誤')
         db['video_queue'].delete(id=top1['id'])
         db.query('UPDATE video_queue_status SET status = 0')