|
@@ -57,7 +57,7 @@ app.add_middleware(
|
|
|
allow_origins=["*"],
|
|
|
allow_credentials=True,
|
|
|
allow_methods=["*"],
|
|
|
- allow_headers=["*"],
|
|
|
+ allow_headers=['Accept','Content-Type','X-Requested-With','x-api-key'],
|
|
|
)
|
|
|
SECRET_KEY = "df2f77bd544240801a048bd4293afd8eeb7fff3cb7050e42c791db4b83ebadcd"
|
|
|
ALGORITHM = "HS256"
|
|
@@ -282,7 +282,14 @@ async def register(request: util.models.register_req):
|
|
|
user_obj = first(db.query('SELECT * FROM users where username ="'+str(request.username)+'"'))
|
|
|
|
|
|
if user_obj == None:
|
|
|
- id = user_register(request)
|
|
|
+ reg_model = util.models.register_addition()
|
|
|
+ reg_model.username = request.username
|
|
|
+ reg_model.email = request.email
|
|
|
+ reg_model.password =request.password
|
|
|
+ reg_model.left_time = 60
|
|
|
+
|
|
|
+ id = user_register(reg_model)
|
|
|
+
|
|
|
result = util.user.add_to_basic_role(id)
|
|
|
print(result)
|
|
|
if type(id) is int:
|
|
@@ -1071,7 +1078,7 @@ def gen_video_queue(name_hash,name,text_content, image_urls,avatar,multiLang,vid
|
|
|
db['video_queue'].insert({'name_hash':name_hash,'name':name,'text_content':txt_content_seperate_by_dot
|
|
|
,'image_urls':img_urls_seperate_by_dot,'multiLang':multiLang,'video_type':'short','avatar':avatar,'timestamp':time_stamp,'freeTrial':freeTrial})
|
|
|
while True:
|
|
|
-
|
|
|
+ db = dataset.connect('mysql://choozmo:pAssw0rd@db.ptt.cx:3306/AI_anchor?charset=utf8mb4')
|
|
|
if first(db.query('SELECT * FROM video_queue_status'))['status'] == 1:#only one row in this table, which is the id 1 one
|
|
|
print('another process running, leave loop')#1 means already running
|
|
|
break
|
|
@@ -1119,8 +1126,10 @@ def gen_video_queue(name_hash,name,text_content, image_urls,avatar,multiLang,vid
|
|
|
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')
|
|
|
+ db.close()
|
|
|
db.close()
|
|
|
|
|
|
def gen_video_queue_eng(name_hash,name,text_content, image_urls,sub_titles,avatar,video_id,freeTrial):
|
|
@@ -1147,6 +1156,7 @@ def gen_video_queue_eng(name_hash,name,text_content, image_urls,sub_titles,avata
|
|
|
db['video_queue'].insert({'name_hash':name_hash,'name':name,'text_content':txt_content_seperate_by_dot,
|
|
|
'image_urls':img_urls_seperate_by_dot,'subtitles':subtitles_seperate_by_dot,'video_type':'eng','avatar':avatar,'timestamp':time_stamp,'freeTrial':freeTrial})
|
|
|
while True:
|
|
|
+ db = dataset.connect('mysql://choozmo:pAssw0rd@db.ptt.cx:3306/AI_anchor?charset=utf8mb4')
|
|
|
if first(db.query('SELECT * FROM video_queue_status'))['status'] == 1:#only one row in this table, which is the id 1 one
|
|
|
print('another process running, leave loop')
|
|
|
break
|
|
@@ -1168,12 +1178,14 @@ def gen_video_queue_eng(name_hash,name,text_content, image_urls,sub_titles,avata
|
|
|
notify_group('影片錯誤')
|
|
|
db['video_queue'].delete(id=top1['id'])
|
|
|
db.query('UPDATE video_queue_status SET status = 0')
|
|
|
+ db.close()
|
|
|
db.close()
|
|
|
|
|
|
def gen_avatar(name_hash, imgurl):
|
|
|
db_check()
|
|
|
db['avatar_queue'].insert({'name_hash':name_hash,'imgurl':imgurl})
|
|
|
while True:
|
|
|
+
|
|
|
statement = 'SELECT * FROM avatar_service_status'#only one row in this table, which is the id 1 one
|
|
|
status = -1
|
|
|
for row in db.query(statement):
|