|
@@ -44,8 +44,7 @@ import gSlide
|
|
import aiofiles
|
|
import aiofiles
|
|
import json
|
|
import json
|
|
import util.user
|
|
import util.user
|
|
-pymysql.install_as_MySQLdb()
|
|
|
|
-
|
|
|
|
|
|
+db = dataset.connect('mysql://choozmo:pAssw0rd@db.ptt.cx:3306/AI_anchor?charset=utf8mb4')
|
|
app = FastAPI()
|
|
app = FastAPI()
|
|
|
|
|
|
mode = 'run'
|
|
mode = 'run'
|
|
@@ -157,7 +156,7 @@ async def make_video_slide(request: Request, response: Response, Authorize: Auth
|
|
|
|
|
|
@app.post('/user_profile', response_class=HTMLResponse)
|
|
@app.post('/user_profile', response_class=HTMLResponse)
|
|
async def user_profile(token: str = Depends(oauth2_scheme)):
|
|
async def user_profile(token: str = Depends(oauth2_scheme)):
|
|
- db = dataset.connect('mysql://choozmo:pAssw0rd@db.ptt.cx:3306/AI_anchor?charset=utf8mb4')
|
|
|
|
|
|
+
|
|
user_id = get_user_id(token)
|
|
user_id = get_user_id(token)
|
|
user_obj = first(db.query('SELECT * FROM users where id ="'+str(user_id)+'"'))
|
|
user_obj = first(db.query('SELECT * FROM users where id ="'+str(user_id)+'"'))
|
|
|
|
|
|
@@ -181,7 +180,6 @@ async def user_profile(token: str = Depends(oauth2_scheme)):
|
|
|
|
|
|
@app.post('/edit_profile')
|
|
@app.post('/edit_profile')
|
|
async def edit_profile(userModel : util.models.UserProfile ,token: str = Depends(oauth2_scheme)):
|
|
async def edit_profile(userModel : util.models.UserProfile ,token: str = Depends(oauth2_scheme)):
|
|
- db = dataset.connect('mysql://choozmo:pAssw0rd@db.ptt.cx:3306/AI_anchor?charset=utf8mb4')
|
|
|
|
print(token)
|
|
print(token)
|
|
user_id = get_user_id(token)
|
|
user_id = get_user_id(token)
|
|
print(user_id)
|
|
print(user_id)
|
|
@@ -197,7 +195,7 @@ async def get_login_and_register_page(request: Request):
|
|
|
|
|
|
@app.post("/login")
|
|
@app.post("/login")
|
|
async def login_for_access_token(request: Request, form_data: OAuth2PasswordRequestForm = Depends(), Authorize: AuthJWT = Depends()):
|
|
async def login_for_access_token(request: Request, form_data: OAuth2PasswordRequestForm = Depends(), Authorize: AuthJWT = Depends()):
|
|
- db = dataset.connect('mysql://choozmo:pAssw0rd@db.ptt.cx:3306/AI_anchor?charset=utf8mb4')
|
|
|
|
|
|
+
|
|
user = authenticate_user(form_data.username, form_data.password)
|
|
user = authenticate_user(form_data.username, form_data.password)
|
|
if not user:
|
|
if not user:
|
|
raise HTTPException(
|
|
raise HTTPException(
|
|
@@ -226,7 +224,6 @@ async def login_for_access_token(request: Request, form_data: OAuth2PasswordRequ
|
|
|
|
|
|
@app.post("/token")
|
|
@app.post("/token")
|
|
async def access_token(form_data: OAuth2PasswordRequestForm = Depends(), Authorize: AuthJWT = Depends()):
|
|
async def access_token(form_data: OAuth2PasswordRequestForm = Depends(), Authorize: AuthJWT = Depends()):
|
|
- db = dataset.connect('mysql://choozmo:pAssw0rd@db.ptt.cx:3306/AI_anchor?charset=utf8mb4')
|
|
|
|
user = authenticate_user(form_data.username, form_data.password)
|
|
user = authenticate_user(form_data.username, form_data.password)
|
|
if not user:
|
|
if not user:
|
|
raise HTTPException(
|
|
raise HTTPException(
|
|
@@ -243,7 +240,6 @@ async def access_token(form_data: OAuth2PasswordRequestForm = Depends(), Authori
|
|
#前後端分離完全實現後拔除
|
|
#前後端分離完全實現後拔除
|
|
@app.post("/register_old")
|
|
@app.post("/register_old")
|
|
async def register_old(request: Request):
|
|
async def register_old(request: Request):
|
|
- db = dataset.connect('mysql://choozmo:pAssw0rd@db.ptt.cx:3306/AI_anchor?charset=utf8mb4')
|
|
|
|
user = util.models.User(**await request.form())
|
|
user = util.models.User(**await request.form())
|
|
user_obj = first(db.query('SELECT * FROM users where username ="'+str(user.username)+'"'))
|
|
user_obj = first(db.query('SELECT * FROM users where username ="'+str(user.username)+'"'))
|
|
if user_obj == None:
|
|
if user_obj == None:
|
|
@@ -262,7 +258,6 @@ async def register_old(request: Request):
|
|
|
|
|
|
@app.post("/register")
|
|
@app.post("/register")
|
|
async def register(request: util.models.register_req):
|
|
async def register(request: util.models.register_req):
|
|
- db = dataset.connect('mysql://choozmo:pAssw0rd@db.ptt.cx:3306/AI_anchor?charset=utf8mb4')
|
|
|
|
user_obj = first(db.query('SELECT * FROM users where username ="'+str(request.username)+'"'))
|
|
user_obj = first(db.query('SELECT * FROM users where username ="'+str(request.username)+'"'))
|
|
|
|
|
|
if user_obj == None:
|
|
if user_obj == None:
|
|
@@ -285,21 +280,18 @@ def logout(request: Request, Authorize: AuthJWT = Depends()):
|
|
|
|
|
|
@app.post('/get_role')
|
|
@app.post('/get_role')
|
|
async def get_role(token: str = Depends(oauth2_scheme)):
|
|
async def get_role(token: str = Depends(oauth2_scheme)):
|
|
- db = dataset.connect('mysql://choozmo:pAssw0rd@db.ptt.cx:3306/AI_anchor?charset=utf8mb4')
|
|
|
|
user_id = util.user.get_user_id(token)
|
|
user_id = util.user.get_user_id(token)
|
|
roles = util.user.get_user_role(user_id)
|
|
roles = util.user.get_user_role(user_id)
|
|
return roles
|
|
return roles
|
|
|
|
|
|
@app.post('/create_role')
|
|
@app.post('/create_role')
|
|
async def get_role(token: str = Depends(oauth2_scheme)):
|
|
async def get_role(token: str = Depends(oauth2_scheme)):
|
|
- db = dataset.connect('mysql://choozmo:pAssw0rd@db.ptt.cx:3306/AI_anchor?charset=utf8mb4')
|
|
|
|
user_id = get_user_id(token)
|
|
user_id = get_user_id(token)
|
|
|
|
|
|
return user_id
|
|
return user_id
|
|
|
|
|
|
@app.post('/get_avatar_by_role')
|
|
@app.post('/get_avatar_by_role')
|
|
async def get_role(token: str = Depends(oauth2_scheme)):
|
|
async def get_role(token: str = Depends(oauth2_scheme)):
|
|
- db = dataset.connect('mysql://choozmo:pAssw0rd@db.ptt.cx:3306/AI_anchor?charset=utf8mb4')
|
|
|
|
user_id = util.user.get_user_id(token)
|
|
user_id = util.user.get_user_id(token)
|
|
roles = util.user.get_user_role(user_id)
|
|
roles = util.user.get_user_role(user_id)
|
|
|
|
|
|
@@ -307,7 +299,6 @@ async def get_role(token: str = Depends(oauth2_scheme)):
|
|
|
|
|
|
@app.get('/verify_email')
|
|
@app.get('/verify_email')
|
|
async def verify_email(code):
|
|
async def verify_email(code):
|
|
- db = dataset.connect('mysql://choozmo:pAssw0rd@db.ptt.cx:3306/AI_anchor?charset=utf8mb4')
|
|
|
|
veri_obj = first(db.query('SELECT * FROM register_veri_code where code ="'+str(code)+'"'))
|
|
veri_obj = first(db.query('SELECT * FROM register_veri_code where code ="'+str(code)+'"'))
|
|
if veri_obj != None:
|
|
if veri_obj != None:
|
|
db['register_veri_code'].delete(code=code)
|
|
db['register_veri_code'].delete(code=code)
|
|
@@ -324,7 +315,6 @@ async def reset_pwd_page():
|
|
@app.get('/send_reset_pwd')
|
|
@app.get('/send_reset_pwd')
|
|
async def send_reset_pwd(user_id,email):
|
|
async def send_reset_pwd(user_id,email):
|
|
code = str(time.time()).replace('.','')
|
|
code = str(time.time()).replace('.','')
|
|
- db = dataset.connect('mysql://choozmo:pAssw0rd@db.ptt.cx:3306/AI_anchor?charset=utf8mb4')
|
|
|
|
db['reset_pw_code'].insert({'code':code,'user_id':user_id,'email':email})
|
|
db['reset_pw_code'].insert({'code':code,'user_id':user_id,'email':email})
|
|
msg = '請至點擊網址以重設密碼 : https://www.choozmo.com:8887/reset_pwd_page 通行碼為 '+ code
|
|
msg = '請至點擊網址以重設密碼 : https://www.choozmo.com:8887/reset_pwd_page 通行碼為 '+ code
|
|
print(msg)
|
|
print(msg)
|
|
@@ -344,7 +334,6 @@ async def send_reset_pwd(user_id,email):
|
|
|
|
|
|
@app.post('/reset_pwd')
|
|
@app.post('/reset_pwd')
|
|
async def reset_password(req :util.models.reset_pwd):
|
|
async def reset_password(req :util.models.reset_pwd):
|
|
- db = dataset.connect('mysql://choozmo:pAssw0rd@db.ptt.cx:3306/AI_anchor?charset=utf8mb4')
|
|
|
|
print(req.code)
|
|
print(req.code)
|
|
veri_obj = next(iter(db.query('SELECT * FROM reset_pw_code where code ="'+str(req.code)+'"')))
|
|
veri_obj = next(iter(db.query('SELECT * FROM reset_pw_code where code ="'+str(req.code)+'"')))
|
|
print(veri_obj['user_id'])
|
|
print(veri_obj['user_id'])
|
|
@@ -481,7 +470,6 @@ async def make_anchor_video_long(req:util.models.request,token: str = Depends(oa
|
|
video_id = save_history(req,name_hash,user_id)
|
|
video_id = save_history(req,name_hash,user_id)
|
|
x = threading.Thread(target=gen_video_long_queue, args=(name_hash,req.name, req.text_content, req.image_urls,int(req.avatar),req.multiLang,video_id,user_id))
|
|
x = threading.Thread(target=gen_video_long_queue, args=(name_hash,req.name, req.text_content, req.image_urls,int(req.avatar),req.multiLang,video_id,user_id))
|
|
x.start()
|
|
x.start()
|
|
- db = dataset.connect('mysql://choozmo:pAssw0rd@db.ptt.cx:3306/AI_anchor?charset=utf8mb4')
|
|
|
|
returnMsg = ''
|
|
returnMsg = ''
|
|
if first(db.query('SELECT COUNT(1) FROM video_queue'))['COUNT(1)'] >= 3:
|
|
if first(db.query('SELECT COUNT(1) FROM video_queue'))['COUNT(1)'] >= 3:
|
|
returnMsg = {'msg':{'eng':'There are many videos have been processing, please wait.','zh':'目前有多部影片處理中,煩請耐心等候'}}
|
|
returnMsg = {'msg':{'eng':'There are many videos have been processing, please wait.','zh':'目前有多部影片處理中,煩請耐心等候'}}
|
|
@@ -519,7 +507,6 @@ async def make_anchor_video(req:util.models.request,token: str = Depends(oauth2_
|
|
video_id = save_history(req,name_hash,user_id)
|
|
video_id = save_history(req,name_hash,user_id)
|
|
x = threading.Thread(target=gen_video_queue, args=(name_hash,req.name, req.text_content, req.image_urls,int(req.avatar),req.multiLang,video_id,user_id))
|
|
x = threading.Thread(target=gen_video_queue, args=(name_hash,req.name, req.text_content, req.image_urls,int(req.avatar),req.multiLang,video_id,user_id))
|
|
x.start()
|
|
x.start()
|
|
- db = dataset.connect('mysql://choozmo:pAssw0rd@db.ptt.cx:3306/AI_anchor?charset=utf8mb4')
|
|
|
|
if first(db.query('SELECT COUNT(1) FROM video_queue'))['COUNT(1)'] >= 3:
|
|
if first(db.query('SELECT COUNT(1) FROM video_queue'))['COUNT(1)'] >= 3:
|
|
return {'msg':{'eng':'There are many videos have been processing, please wait.','zh':'目前有多部影片處理中,煩請耐心等候'}}
|
|
return {'msg':{'eng':'There are many videos have been processing, please wait.','zh':'目前有多部影片處理中,煩請耐心等候'}}
|
|
else:
|
|
else:
|
|
@@ -547,7 +534,6 @@ async def make_anchor_video_eng(req:util.models.request_eng,token: str = Depends
|
|
video_id = save_history(req,name_hash, user_id)
|
|
video_id = save_history(req,name_hash, user_id)
|
|
x = threading.Thread(target=gen_video_queue_eng, args=(name_hash,req.name, req.text_content, req.image_urls,req.sub_titles,int(req.avatar),video_id))
|
|
x = threading.Thread(target=gen_video_queue_eng, args=(name_hash,req.name, req.text_content, req.image_urls,req.sub_titles,int(req.avatar),video_id))
|
|
x.start()
|
|
x.start()
|
|
- db = dataset.connect('mysql://choozmo:pAssw0rd@db.ptt.cx:3306/AI_anchor?charset=utf8mb4')
|
|
|
|
if first(db.query('SELECT COUNT(1) FROM video_queue'))['COUNT(1)'] >= 3:
|
|
if first(db.query('SELECT COUNT(1) FROM video_queue'))['COUNT(1)'] >= 3:
|
|
return {'msg':{'eng':'There are many videos have been processing, please wait.','zh':'目前有多部影片處理中,煩請耐心等候'}}
|
|
return {'msg':{'eng':'There are many videos have been processing, please wait.','zh':'目前有多部影片處理中,煩請耐心等候'}}
|
|
else:
|
|
else:
|
|
@@ -556,7 +542,6 @@ async def make_anchor_video_eng(req:util.models.request_eng,token: str = Depends
|
|
|
|
|
|
@app.post("/save_draft")
|
|
@app.post("/save_draft")
|
|
async def save_draft(req:util.models.video_draft,token: str = Depends(oauth2_scheme)):
|
|
async def save_draft(req:util.models.video_draft,token: str = Depends(oauth2_scheme)):
|
|
- db = dataset.connect('mysql://choozmo:pAssw0rd@db.ptt.cx:3306/AI_anchor?charset=utf8mb4')
|
|
|
|
user_id = get_user_id(token)
|
|
user_id = get_user_id(token)
|
|
|
|
|
|
txt_content_seperate_by_dot = ''
|
|
txt_content_seperate_by_dot = ''
|
|
@@ -582,7 +567,6 @@ async def save_draft(req:util.models.video_draft,token: str = Depends(oauth2_sch
|
|
|
|
|
|
@app.post('/draft_list')
|
|
@app.post('/draft_list')
|
|
async def draft_list(token: str = Depends(oauth2_scheme)):
|
|
async def draft_list(token: str = Depends(oauth2_scheme)):
|
|
- db = dataset.connect('mysql://choozmo:pAssw0rd@db.ptt.cx:3306/AI_anchor?charset=utf8mb4')
|
|
|
|
user_id = get_user_id(token)
|
|
user_id = get_user_id(token)
|
|
statement = 'SELECT * FROM draft WHERE user_id='+str(user_id)+' ORDER BY time_stamp DESC LIMIT 50'
|
|
statement = 'SELECT * FROM draft WHERE user_id='+str(user_id)+' ORDER BY time_stamp DESC LIMIT 50'
|
|
logs = []
|
|
logs = []
|
|
@@ -593,7 +577,6 @@ async def draft_list(token: str = Depends(oauth2_scheme)):
|
|
|
|
|
|
@app.post('/del_draft')
|
|
@app.post('/del_draft')
|
|
async def del_draft(id_obj:util.models.id_obj,token: str = Depends(oauth2_scheme)):
|
|
async def del_draft(id_obj:util.models.id_obj,token: str = Depends(oauth2_scheme)):
|
|
- db = dataset.connect('mysql://choozmo:pAssw0rd@db.ptt.cx:3306/AI_anchor?charset=utf8mb4')
|
|
|
|
user_id = get_user_id(token)
|
|
user_id = get_user_id(token)
|
|
statement = 'SELECT * FROM draft WHERE user_id="'+str(user_id)+'" and id ="'+str(id_obj.id)+'"'
|
|
statement = 'SELECT * FROM draft WHERE user_id="'+str(user_id)+'" and id ="'+str(id_obj.id)+'"'
|
|
if first(db.query(statement)) is not None:
|
|
if first(db.query(statement)) is not None:
|
|
@@ -610,7 +593,6 @@ async def history_input_old(request: Request, Authorize: AuthJWT = Depends()):
|
|
Authorize.jwt_required()
|
|
Authorize.jwt_required()
|
|
current_user = Authorize.get_jwt_subject()
|
|
current_user = Authorize.get_jwt_subject()
|
|
|
|
|
|
- db = dataset.connect('mysql://choozmo:pAssw0rd@db.ptt.cx:3306/AI_anchor?charset=utf8mb4')
|
|
|
|
user_id = first(db.query('SELECT * FROM users where username="' + current_user +'"'))['id']
|
|
user_id = first(db.query('SELECT * FROM users where username="' + current_user +'"'))['id']
|
|
statement = 'SELECT * FROM history_input WHERE user_id="'+str(user_id)+'" ORDER BY timestamp DESC LIMIT 50'
|
|
statement = 'SELECT * FROM history_input WHERE user_id="'+str(user_id)+'" ORDER BY timestamp DESC LIMIT 50'
|
|
|
|
|
|
@@ -622,7 +604,6 @@ async def history_input_old(request: Request, Authorize: AuthJWT = Depends()):
|
|
|
|
|
|
@app.post("/history_input")
|
|
@app.post("/history_input")
|
|
async def history_input(token: str = Depends(oauth2_scheme)):
|
|
async def history_input(token: str = Depends(oauth2_scheme)):
|
|
- db = dataset.connect('mysql://choozmo:pAssw0rd@db.ptt.cx:3306/AI_anchor?charset=utf8mb4')
|
|
|
|
user_id = get_user_id(token)
|
|
user_id = get_user_id(token)
|
|
user_obj = first(db.query('SELECT * FROM users where id ="'+str(user_id)+'"'))
|
|
user_obj = first(db.query('SELECT * FROM users where id ="'+str(user_id)+'"'))
|
|
statement = 'SELECT * FROM history_input WHERE user_id="'+str(user_id)+'" ORDER BY timestamp DESC LIMIT 50'
|
|
statement = 'SELECT * FROM history_input WHERE user_id="'+str(user_id)+'" ORDER BY timestamp DESC LIMIT 50'
|
|
@@ -646,7 +627,6 @@ def authjwt_exception_handler(request: Request, exc: AuthJWTException):
|
|
)
|
|
)
|
|
|
|
|
|
def get_user_id(token):
|
|
def get_user_id(token):
|
|
- db = dataset.connect('mysql://choozmo:pAssw0rd@db.ptt.cx:3306/AI_anchor?charset=utf8mb4')
|
|
|
|
credentials_exception = HTTPException(
|
|
credentials_exception = HTTPException(
|
|
status_code=status.HTTP_401_UNAUTHORIZED,
|
|
status_code=status.HTTP_401_UNAUTHORIZED,
|
|
detail="Could not validate credentials",
|
|
detail="Could not validate credentials",
|
|
@@ -667,14 +647,12 @@ def get_user_id(token):
|
|
return user_id
|
|
return user_id
|
|
|
|
|
|
def check_user_exists(username):
|
|
def check_user_exists(username):
|
|
- db = dataset.connect('mysql://choozmo:pAssw0rd@db.ptt.cx:3306/AI_anchor?charset=utf8mb4')
|
|
|
|
if int(next(iter(db.query('SELECT COUNT(*) FROM AI_anchor.users WHERE username = "'+username+'"')))['COUNT(*)']) > 0:
|
|
if int(next(iter(db.query('SELECT COUNT(*) FROM AI_anchor.users WHERE username = "'+username+'"')))['COUNT(*)']) > 0:
|
|
return True
|
|
return True
|
|
else:
|
|
else:
|
|
return False
|
|
return False
|
|
|
|
|
|
def get_user(username: str):
|
|
def get_user(username: str):
|
|
- db = dataset.connect('mysql://choozmo:pAssw0rd@db.ptt.cx:3306/AI_anchor?charset=utf8mb4')
|
|
|
|
if not check_user_exists(username): # if user don't exist
|
|
if not check_user_exists(username): # if user don't exist
|
|
return False
|
|
return False
|
|
user_dict = next(
|
|
user_dict = next(
|
|
@@ -683,7 +661,7 @@ def get_user(username: str):
|
|
return user
|
|
return user
|
|
|
|
|
|
def user_register(user):
|
|
def user_register(user):
|
|
- db = dataset.connect('mysql://choozmo:pAssw0rd@db.ptt.cx:3306/AI_anchor?charset=utf8mb4')
|
|
|
|
|
|
+
|
|
table = db['users']
|
|
table = db['users']
|
|
user.password = get_password_hash(user.password)
|
|
user.password = get_password_hash(user.password)
|
|
id = table.insert(dict(user))
|
|
id = table.insert(dict(user))
|
|
@@ -694,7 +672,7 @@ def get_password_hash(password):
|
|
def verify_password(plain_password, hashed_password):
|
|
def verify_password(plain_password, hashed_password):
|
|
return pwd_context.verify(plain_password, hashed_password)
|
|
return pwd_context.verify(plain_password, hashed_password)
|
|
def authenticate_user(username: str, password: str):
|
|
def authenticate_user(username: str, password: str):
|
|
- db = dataset.connect('mysql://choozmo:pAssw0rd@db.ptt.cx:3306/AI_anchor?charset=utf8mb4')
|
|
|
|
|
|
+
|
|
if not check_user_exists(username): # if user don't exist
|
|
if not check_user_exists(username): # if user don't exist
|
|
return False
|
|
return False
|
|
user_dict = next(iter(db.query('SELECT * FROM AI_anchor.users where username ="'+username+'"')))
|
|
user_dict = next(iter(db.query('SELECT * FROM AI_anchor.users where username ="'+username+'"')))
|
|
@@ -712,7 +690,7 @@ def create_access_token(data: dict, expires_delta):
|
|
return encoded_jwt
|
|
return encoded_jwt
|
|
|
|
|
|
def save_history(req,name_hash,user_id):
|
|
def save_history(req,name_hash,user_id):
|
|
- db = dataset.connect('mysql://choozmo:pAssw0rd@db.ptt.cx:3306/AI_anchor?charset=utf8mb4')
|
|
|
|
|
|
+
|
|
log_table = db['history_input']
|
|
log_table = db['history_input']
|
|
txt_content_seperate_by_dot = ''
|
|
txt_content_seperate_by_dot = ''
|
|
for txt in req.text_content:
|
|
for txt in req.text_content:
|
|
@@ -743,7 +721,7 @@ def notify_group(msg):
|
|
|
|
|
|
|
|
|
|
def gen_video_long_queue(name_hash,name,text_content, image_urls,avatar,multiLang,video_id,user_id):
|
|
def gen_video_long_queue(name_hash,name,text_content, image_urls,avatar,multiLang,video_id,user_id):
|
|
- db = dataset.connect('mysql://choozmo:pAssw0rd@db.ptt.cx:3306/AI_anchor?charset=utf8mb4')
|
|
|
|
|
|
+
|
|
time_stamp = datetime.fromtimestamp(time.time()).strftime("%Y-%m-%d %H:%M:%S")
|
|
time_stamp = datetime.fromtimestamp(time.time()).strftime("%Y-%m-%d %H:%M:%S")
|
|
txt_content_seperate_by_dot = ''
|
|
txt_content_seperate_by_dot = ''
|
|
for txt in text_content:
|
|
for txt in text_content:
|
|
@@ -801,7 +779,7 @@ def gen_video_long_queue(name_hash,name,text_content, image_urls,avatar,multiLan
|
|
db['video_queue'].delete(id=top1['id'])
|
|
db['video_queue'].delete(id=top1['id'])
|
|
db.query('UPDATE video_queue_status SET status = 0')
|
|
db.query('UPDATE video_queue_status SET status = 0')
|
|
def gen_video_queue(name_hash,name,text_content, image_urls,avatar,multiLang,video_id,user_id):
|
|
def gen_video_queue(name_hash,name,text_content, image_urls,avatar,multiLang,video_id,user_id):
|
|
- db = dataset.connect('mysql://choozmo:pAssw0rd@db.ptt.cx:3306/AI_anchor?charset=utf8mb4')
|
|
|
|
|
|
+
|
|
time_stamp = datetime.fromtimestamp(time.time()).strftime("%Y-%m-%d %H:%M:%S")
|
|
time_stamp = datetime.fromtimestamp(time.time()).strftime("%Y-%m-%d %H:%M:%S")
|
|
txt_content_seperate_by_dot = ''
|
|
txt_content_seperate_by_dot = ''
|
|
for txt in text_content:
|
|
for txt in text_content:
|
|
@@ -860,7 +838,7 @@ def gen_video_queue(name_hash,name,text_content, image_urls,avatar,multiLang,vid
|
|
db.query('UPDATE video_queue_status SET status = 0')
|
|
db.query('UPDATE video_queue_status SET status = 0')
|
|
|
|
|
|
def gen_video_queue_eng(name_hash,name,text_content, image_urls,sub_titles,avatar,video_id):
|
|
def gen_video_queue_eng(name_hash,name,text_content, image_urls,sub_titles,avatar,video_id):
|
|
- db = dataset.connect('mysql://choozmo:pAssw0rd@db.ptt.cx:3306/AI_anchor?charset=utf8mb4')
|
|
|
|
|
|
+
|
|
time_stamp = datetime.fromtimestamp(time.time()).strftime("%Y-%m-%d %H:%M:%S")
|
|
time_stamp = datetime.fromtimestamp(time.time()).strftime("%Y-%m-%d %H:%M:%S")
|
|
txt_content_seperate_by_dot = ''
|
|
txt_content_seperate_by_dot = ''
|
|
for txt in text_content:
|
|
for txt in text_content:
|
|
@@ -899,7 +877,7 @@ def gen_video_queue_eng(name_hash,name,text_content, image_urls,sub_titles,avata
|
|
db.query('UPDATE video_queue_status SET status = 0')
|
|
db.query('UPDATE video_queue_status SET status = 0')
|
|
|
|
|
|
def gen_avatar(name_hash, imgurl):
|
|
def gen_avatar(name_hash, imgurl):
|
|
- db = dataset.connect('mysql://choozmo:pAssw0rd@db.ptt.cx:3306/AI_anchor?charset=utf8mb4')
|
|
|
|
|
|
+
|
|
db['avatar_queue'].insert({'name_hash':name_hash,'imgurl':imgurl})
|
|
db['avatar_queue'].insert({'name_hash':name_hash,'imgurl':imgurl})
|
|
while True:
|
|
while True:
|
|
statement = 'SELECT * FROM avatar_service_status'#only one row in this table, which is the id 1 one
|
|
statement = 'SELECT * FROM avatar_service_status'#only one row in this table, which is the id 1 one
|