|
@@ -54,11 +54,16 @@ print("db loaded")
|
|
|
mode = 'run'
|
|
|
app.add_middleware(
|
|
|
CORSMiddleware,
|
|
|
- allow_origins=["*"],
|
|
|
+ #allow_origins=["*"],
|
|
|
+ allow_origins=["https://show.choozmo.com","https://video.choozmo.com"],
|
|
|
allow_credentials=True,
|
|
|
- allow_methods=["*"],
|
|
|
- allow_headers=['Accept','Content-Type','X-Requested-With','x-api-key'],
|
|
|
+ allow_methods=["POST","GET"],
|
|
|
+ #allow_headers=["*"],
|
|
|
+ allow_headers = ["Authorization","Accept","accept","Origin","Content-Type","X-LS-CORS-Template","X-LS-Auth-Token","X-LS-Auth-User-Token","Content-Type","X-LS-Sync-Result","X-LS-Sequence","token"],
|
|
|
)
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
SECRET_KEY = "df2f77bd544240801a048bd4293afd8eeb7fff3cb7050e42c791db4b83ebadcd"
|
|
|
ALGORITHM = "HS256"
|
|
|
ACCESS_TOKEN_EXPIRE_DAYS = 5
|
|
@@ -282,14 +287,10 @@ 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:
|
|
|
- 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)
|
|
|
|
|
|
+ id = user_register(request)
|
|
|
+ udata = dict(id=id, left_time=60)
|
|
|
+ db['users'].update(udata, ['id'])
|
|
|
result = util.user.add_to_basic_role(id)
|
|
|
print(result)
|
|
|
if type(id) is int:
|
|
@@ -317,6 +318,8 @@ async def register_by_invite(request: util.models.register_invite_req):
|
|
|
request.invite_code = sha.hexdigest()
|
|
|
id = user_register(request)
|
|
|
result = util.user.add_to_basic_role(id)
|
|
|
+ udata = dict(id=id, left_time=60)
|
|
|
+ db['users'].update(udata, ['id'])
|
|
|
if type(id) is int:
|
|
|
code = str(time.time()).replace('.','')
|
|
|
db['register_veri_code'].insert({'code':code,'user_id':id})
|
|
@@ -1085,8 +1088,12 @@ def gen_video_queue(name_hash,name,text_content, image_urls,avatar,multiLang,vid
|
|
|
if first(db.query('SELECT COUNT(1) FROM video_queue where video_type="short"'))['COUNT(1)'] == 0:
|
|
|
print('all finish, leave loop')
|
|
|
break
|
|
|
- top1 = first(db.query('SELECT * FROM video_queue where video_type="short"'))
|
|
|
try:
|
|
|
+ db.close()
|
|
|
+ db = dataset.connect('mysql://choozmo:pAssw0rd@db.ptt.cx:3306/AI_anchor?charset=utf8mb4')
|
|
|
+ top1 = first(db.query('SELECT * FROM video_queue where video_type="short"'))
|
|
|
+ print(top1)
|
|
|
+ print(top1['name_hash'])
|
|
|
# if True:
|
|
|
db.query('UPDATE video_queue_status SET status = 1;')
|
|
|
c = rpyc.connect("localhost", 8858)
|
|
@@ -1120,7 +1127,7 @@ def gen_video_queue(name_hash,name,text_content, image_urls,avatar,multiLang,vid
|
|
|
left_time = left_time - vid_duration
|
|
|
if user_id != -1:
|
|
|
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_group(top1['name']+"的影片已經產生完成囉! www.choozmo.com:8168/"+video_sub_folder+top1['name_hash']+".mp4")
|
|
|
#notify_line_user(name+"的影片已經產生完成囉! www.choozmo.com:8168/"+video_sub_folder+name_hash+".mp4", line_token)
|
|
|
except Exception as e:
|
|
|
logging.error(traceback.format_exc())
|
|
@@ -1170,9 +1177,9 @@ def gen_video_queue_eng(name_hash,name,text_content, image_urls,sub_titles,avata
|
|
|
c._config['sync_request_timeout'] = None
|
|
|
remote_svc = c.root
|
|
|
my_answer = remote_svc.call_video_eng(top1['name_hash'],top1['name'],top1['text_content'].split(','), top1['image_urls'].split(','),top1['subtitles'].split(','),top1['avatar'],top1['freeTrial']) # method call
|
|
|
- shutil.copy(tmp_video_dir+top1['name_hash']+'.mp4',video_dest+top1['name_hash']+'.mp4')
|
|
|
+ shutil.copy(tmp_video_dir+top1['name']+'.mp4',video_dest+top1['name_hash']+'.mp4')
|
|
|
os.remove(tmp_video_dir+top1['name_hash']+'.mp4')
|
|
|
- notify_group(name+"(ENG)的影片已經產生完成囉! www.choozmo.com:8168/"+video_sub_folder+name_hash+".mp4")
|
|
|
+ notify_group(top1['name']+"(ENG)的影片已經產生完成囉! www.choozmo.com:8168/"+video_sub_folder+['name_hash']+".mp4")
|
|
|
except:
|
|
|
print('video generation error')
|
|
|
notify_group('影片錯誤')
|