|
@@ -70,13 +70,17 @@ oauth2_scheme = OAuth2PasswordBearer(tokenUrl="token")
|
|
|
|
|
|
tmp_video_dir = '../OpenshotService/tmp_video/'
|
|
|
tmp_avatar_dir = '../../face_swap/tmp_avatar/' #change source face path here
|
|
|
-
|
|
|
+resource_server = 'www.choozmo.com:8168/'
|
|
|
+resource_folder = '/var/www/html/'
|
|
|
video_sub_folder = 'ai_anchor_video/'
|
|
|
avatar_sub_folder = 'swap_save/'
|
|
|
tmp_img_sub_folder = 'tmp_img/'
|
|
|
+pttx_sub_folder = 'tmp_pttx/'
|
|
|
img_upload_folder = '/var/www/html/'+tmp_img_sub_folder
|
|
|
video_dest = '/var/www/html/'+video_sub_folder
|
|
|
avatar_dest = '/var/www/html/'+avatar_sub_folder
|
|
|
+pttx_dest = '/var/www/html/'+pttx_sub_folder
|
|
|
+
|
|
|
|
|
|
|
|
|
# @app.get("/index2")
|
|
@@ -247,22 +251,39 @@ async def create_upload_file(file: UploadFile = File(...)):
|
|
|
async with aiofiles.open(img_upload_folder+img_name+'.mp4', 'wb') as out_file:
|
|
|
content = await file.read()
|
|
|
await out_file.write(content)
|
|
|
- return {"msg": 'www.choozmo.com:8168/'+tmp_img_sub_folder+img_name+'.mp4'}
|
|
|
+ return {"msg": resource_server+tmp_img_sub_folder+img_name+'.mp4'}
|
|
|
else:
|
|
|
contents = await file.read()
|
|
|
image = Image.open(io.BytesIO(contents))
|
|
|
image= image.convert("RGB")
|
|
|
image.save(img_upload_folder+img_name+'.jpg')
|
|
|
- return {"msg": 'www.choozmo.com:8168/'+tmp_img_sub_folder+img_name+'.jpg'}
|
|
|
+ return {"msg": resource_server+tmp_img_sub_folder+img_name+'.jpg'}
|
|
|
except Exception as e:
|
|
|
logging.error(traceback.format_exc())
|
|
|
return {'msg':'檔案無法使用'}
|
|
|
|
|
|
+@app.post("/upload_pttx/")
|
|
|
+async def upload_pttx(file: UploadFile = File(...)):
|
|
|
+ try:
|
|
|
+ if "_" in file.filename:
|
|
|
+ return {'msg':'檔案無法使用檔名不能含有"_"符號'}
|
|
|
+ else:
|
|
|
+ pttx_name = file.filename+'_'+str(time.time()).replace('.','')
|
|
|
+ with open(pttx_dest+pttx_name, "wb+") as file_object:
|
|
|
+ file_object.write(file.file.read())
|
|
|
+ return {"msg": resource_server+pttx_sub_folder+pttx_name}
|
|
|
+ except Exception as e:
|
|
|
+ logging.error(traceback.format_exc())
|
|
|
+ return {'msg':'檔案無法使用'}
|
|
|
|
|
|
|
|
|
@app.post("/make_anchor_video_gSlide")
|
|
|
async def make_anchor_video_gSlide(req:models.gSlide_req,token: str = Depends(oauth2_scheme)):
|
|
|
- name, text_content, image_urls = gSlide.parse_slide_url(req.slide_url,eng=False)
|
|
|
+ if req.url_type == 0:
|
|
|
+ name, text_content, image_urls = gSlide.parse_slide_url(req.slide_url,eng=False)
|
|
|
+ else :
|
|
|
+ filename = req.slide_url.replace(resource_server+pttx_sub_folder,resource_folder+pttx_sub_folder)
|
|
|
+ name, text_content, image_urls = gSlide.parse_pttx_url(filename,img_upload_folder,resource_server+tmp_img_sub_folder,eng=False)
|
|
|
if len(image_urls) != len(text_content):
|
|
|
return {'msg':'副標題數量、圖片(影片)數量以及台詞數量必須一致'}
|
|
|
for idx in range(len(image_urls)):
|