瀏覽代碼

调整群发视频

develop
H Vs 2 月之前
父節點
當前提交
f7f21f3461
共有 3 個文件被更改,包括 7 次插入7 次删除
  1. +1
    -1
      resources/messages_resource.py
  2. +4
    -4
      wechat/biz.py
  3. +2
    -2
      wechat/gewe_chat.py

+ 1
- 1
resources/messages_resource.py 查看文件

@@ -23,7 +23,7 @@ class MessagesResource(Resource):

def post(self):
msg = request.get_json()
logger.info(f"收到微信回调消息: {msg}")
logger.info(f"收到微信回调消息: {json.dumps(msg, separators=(',', ':'),ensure_ascii=False)}")
type_name =msg.get("TypeName")
app_id = msg.get("Appid")
# token_id = "f828cb3c-1039-489f-b9ae-7494d1778a15"


+ 4
- 4
wechat/biz.py 查看文件

@@ -242,14 +242,14 @@ def send_video_message(wxchat:gewe_chat.GeWeChatCom, token_id, app_id, agent_wxi
filename = os.path.basename(parsed_url.path)
tmp_file_path = os.path.join(os.getcwd(),'tmp', filename) # 拼接完整路径
thumbnail_path=tmp_file_path.replace('.mp4','.jpg')
video_thumb_url,video_duration =utils.download_video_and_get_thumbnail(file_url,thumbnail_path)

print(f'视频缩略图 {video_thumb_url} 时长 {video_duration}')
if wxchat.forward_video_aeskey == '':
video_thumb_url,video_duration =utils.download_video_and_get_thumbnail(file_url,thumbnail_path)
print(f'视频缩略图 {video_thumb_url} 时长 {video_duration}')

ret,ret_msg,res = wxchat.post_video(token_id, app_id, t, file_url,video_thumb_url,video_duration)
if ret==200:
wxchat.forward_video_aeskey = res["aesKey"]
wxchat.forward_video_cdnvideourl = res["cdnVideoUrl"]
wxchat.forward_video_cdnvideourl = res["cdnThumbUrl"]
wxchat.forward_video_length = res["length"]
else:
ret,ret_msg,res = wxchat.forward_video(token_id, app_id, t, wxchat.forward_video_aeskey, wxchat.forward_video_cdnvideourl, wxchat.forward_video_length)


+ 2
- 2
wechat/gewe_chat.py 查看文件

@@ -374,7 +374,7 @@ class GeWeChatCom:
"toWxid": to_wxid,
"videoUrl": video_url,
"videoDuration":video_duration,
"videoThumbUrl":video_thumb_url
"thumbUrl":video_thumb_url
}
response = requests.post(url=api_url, headers=headers, data=json.dumps(data))
response_object = response.json()
@@ -410,7 +410,7 @@ class GeWeChatCom:
}
response = requests.post(url=api_url, headers=headers, data=json.dumps(data))
response_object = response.json()
return response_object.get('data',None),response_object.get('ret',None),response_object.get('msg',None)
return response_object.get('ret',None),response_object.get('msg',None),response_object.get('data',None)

def add_contacts(self,token_id:str,app_id:str,scene:int,option:int,v3:str,v4:str,content:str):
api_url = f"{self.base_url}/v2/api/contacts/addContacts"


Loading…
取消
儲存