Browse Source

fixing websocket

ming 3 years ago
parent
commit
e2f6109982
1 changed files with 6 additions and 7 deletions
  1. 6 7
      main.py

+ 6 - 7
main.py

@@ -501,7 +501,7 @@ def anchor_video_v2(name,text_content, image_urls,avatar):
     print('sub image made')
     file_prepare_v2(name, name_hash, text_content,image_urls)
     progress = 10
-    await ws.send(str(progress))
+     ws.send(str(progress))
     sub_list=generate_subtitle_image(name_hash,text_content)
     progress = 20
     await ws.send(str(progress))
@@ -662,7 +662,6 @@ def anchor_video_v2(name,text_content, image_urls,avatar):
 
 
 def anchor_video_v3333(name,text_content, image_urls,avatar):
-    ws = create_connection("ws://www.choozmo.com:8888/progress")
     progress = 0
 
     name_hash = str(time.time()).replace('.','')
@@ -670,16 +669,16 @@ def anchor_video_v3333(name,text_content, image_urls,avatar):
     print('sub image made')
     file_prepare_v2(name, name_hash, text_content,image_urls)
     progress = 10
-    ws.send(str(progress))
+    await manager.broadcast(progress)
     sub_list=generate_subtitle_image(name_hash,text_content)
     progress = 20
-    ws.send(str(progress))
+    await manager.broadcast(progress)
     
     progress_per_video = int(40/len(text_content))
     for fname in range(len(text_content)):
         call_achor_video_v2(name_hash+"/"+str(fname))
         progress += progress_per_video
-        ws.send(str(progress))
+        await manager.broadcast(progress)
         print('step finish')
     print('called............................................')
 
@@ -765,7 +764,7 @@ def anchor_video_v3333(name,text_content, image_urls,avatar):
         idx+=1
 
     progress+=10
-    ws.send(str(progress))
+    await manager.broadcast(progress)
     
     LOGO_ED = openshot.FFmpegReader(dir_video+"LOGO_ED.avi")
     LOGO_ED.Open()
@@ -811,7 +810,7 @@ def anchor_video_v3333(name,text_content, image_urls,avatar):
         openshot.Fraction(1, 1), False, False, 3000000)
     w.Open()
     progress = 100
-    ws.send(str(progress))
+    await manager.broadcast(progress)
     #may change duration into t.info.duration
     for n in range(int(t.info.fps)*int(head_duration+main_timer+ED_duration)):
         f=t.GetFrame(n)