|
@@ -18,6 +18,7 @@ import time
|
|
import math
|
|
import math
|
|
import hashlib
|
|
import hashlib
|
|
import re
|
|
import re
|
|
|
|
+import asyncio
|
|
import urllib.request
|
|
import urllib.request
|
|
from fastapi.responses import FileResponse
|
|
from fastapi.responses import FileResponse
|
|
from websocket import create_connection
|
|
from websocket import create_connection
|
|
@@ -473,31 +474,31 @@ def generate_subtitle_image(name_hash,text_content):
|
|
img_list[idx]+=[{"count":len(sub),"path":sv_path}]
|
|
img_list[idx]+=[{"count":len(sub),"path":sv_path}]
|
|
return img_list
|
|
return img_list
|
|
|
|
|
|
-def sendProgress(progress,client_id):
|
|
|
|
- ws = create_connection("ws://www.choozmo.com:8888/progress/"+client_id)
|
|
|
|
- ws.send(str(progress))
|
|
|
|
- ws.close()
|
|
|
|
|
|
+async def sendProgress(progress,client_id):
|
|
|
|
+ await ws = create_connection("ws://www.choozmo.com:8888/progress/"+client_id)
|
|
|
|
+ await ws.send(str(progress))
|
|
|
|
+ await ws.close()
|
|
|
|
|
|
def anchor_video_v2(name,text_content, image_urls,avatar,client_id):
|
|
def anchor_video_v2(name,text_content, image_urls,avatar,client_id):
|
|
|
|
|
|
progress = 0
|
|
progress = 0
|
|
- sendProgress(progress,client_id)
|
|
|
|
|
|
+ asyncio.run(sendProgress(progress,client_id))
|
|
name_hash = str(time.time()).replace('.','')
|
|
name_hash = str(time.time()).replace('.','')
|
|
|
|
|
|
print('sub image made')
|
|
print('sub image made')
|
|
file_prepare_v2(name, name_hash, text_content,image_urls)
|
|
file_prepare_v2(name, name_hash, text_content,image_urls)
|
|
progress = 10
|
|
progress = 10
|
|
- sendProgress(progress,client_id)
|
|
|
|
|
|
+ asyncio.run(sendProgress(progress,client_id))
|
|
sub_list=generate_subtitle_image(name_hash,text_content)
|
|
sub_list=generate_subtitle_image(name_hash,text_content)
|
|
progress = 20
|
|
progress = 20
|
|
- sendProgress(progress,client_id)
|
|
|
|
|
|
+ asyncio.run(sendProgress(progress,client_id))
|
|
|
|
|
|
progress_per_video = int(40/len(text_content))
|
|
progress_per_video = int(40/len(text_content))
|
|
for fname in range(len(text_content)):
|
|
for fname in range(len(text_content)):
|
|
call_achor_video_v2(name_hash+"/"+str(fname),avatar)
|
|
call_achor_video_v2(name_hash+"/"+str(fname),avatar)
|
|
progress += progress_per_video
|
|
progress += progress_per_video
|
|
print('step finish')
|
|
print('step finish')
|
|
- sendProgress(progress,client_id)
|
|
|
|
|
|
+ asyncio.run(sendProgress(progress,client_id))
|
|
print('called............................................')
|
|
print('called............................................')
|
|
|
|
|
|
ck=cKey(0,254,0,270)
|
|
ck=cKey(0,254,0,270)
|
|
@@ -582,7 +583,7 @@ def anchor_video_v2(name,text_content, image_urls,avatar,client_id):
|
|
idx+=1
|
|
idx+=1
|
|
|
|
|
|
progress+=10
|
|
progress+=10
|
|
- sendProgress(progress,client_id)
|
|
|
|
|
|
+ asyncio.run(sendProgress(progress,client_id))
|
|
|
|
|
|
LOGO_ED = openshot.FFmpegReader(dir_video+"LOGO_ED.avi")
|
|
LOGO_ED = openshot.FFmpegReader(dir_video+"LOGO_ED.avi")
|
|
LOGO_ED.Open()
|
|
LOGO_ED.Open()
|
|
@@ -636,14 +637,14 @@ def anchor_video_v2(name,text_content, image_urls,avatar,client_id):
|
|
|
|
|
|
|
|
|
|
progress = 100
|
|
progress = 100
|
|
- sendProgress(progress,client_id)
|
|
|
|
|
|
+ asyncio.run(sendProgress(progress,client_id))
|
|
notify_group(name+"的影片已經產生完成囉! www.choozmo.com:8168/"+name_hash+".mp4")
|
|
notify_group(name+"的影片已經產生完成囉! www.choozmo.com:8168/"+name_hash+".mp4")
|
|
t.Close()
|
|
t.Close()
|
|
w.Close()
|
|
w.Close()
|
|
|
|
|
|
|
|
|
|
progress = 100
|
|
progress = 100
|
|
- sendProgress(progress,client_id)
|
|
|
|
|
|
+ asyncio.run(sendProgress(progress,client_id))
|
|
print("Raw Video done")
|
|
print("Raw Video done")
|
|
print("video at : www.choozmo.com:8168/"+name_hash+".mp4")
|
|
print("video at : www.choozmo.com:8168/"+name_hash+".mp4")
|
|
|
|
|