Browse Source

update url format

ming 3 năm trước cách đây
mục cha
commit
ff2f1ba141
1 tập tin đã thay đổi với 4 bổ sung2 xóa
  1. 4 2
      api/main.py

+ 4 - 2
api/main.py

@@ -96,14 +96,15 @@ async def create_upload_file(file: UploadFile = File(...)):
 
 @app.post("/make_anchor_video_v2")
 async def make_anchor_video_v2(req:request):
+    for idx in range(len(req.image_urls)):
+        if 'http' not in req.image_urls[idx]:
+            req.image_urls[idx] = 'http://'+req.image_urls[idx]
     for txt in req.text_content:
         if re.search('[a-zA-Z]', txt) !=None:
             return {'msg':'輸入字串不能包含英文字!'}
     name_hash = str(time.time()).replace('.','')
     for imgu in req.image_urls:
         try:
-            if 'http' not in imgu:
-                imgu = 'http://'+imgu
             if get_url_type(imgu) =='video/mp4':
                 r=requests.get(imgu)
             else:
@@ -112,6 +113,7 @@ async def make_anchor_video_v2(req:request):
         except:
             return {'msg':"無法辨別圖片網址"+imgu}
     
+    
     save_history(req,name_hash)
     x = threading.Thread(target=gen_video, args=(name_hash,req.name, req.text_content, req.image_urls,int(req.avatar),req.client_id))
     x.start()