mirror of
https://github.com/yincongcyincong/wechat_chatter.git
synced 2026-07-15 10:26:52 +08:00
update size duration
This commit is contained in:
+11
-5
@@ -22,7 +22,7 @@ var (
|
||||
|
||||
userID2NicknameMap sync.Map
|
||||
userID2FileMsgMap sync.Map
|
||||
videoDurationMap sync.Map // targetId -> int32(duration seconds)
|
||||
videoInfoMap sync.Map // targetId -> *VideoInfo
|
||||
)
|
||||
|
||||
type WechatMessage struct {
|
||||
@@ -58,10 +58,16 @@ type SendMsg struct {
|
||||
FilePath string
|
||||
FileType int
|
||||
|
||||
CdnKey string
|
||||
Md5Key string
|
||||
VideoId string
|
||||
Duration int32
|
||||
CdnKey string
|
||||
Md5Key string
|
||||
VideoId string
|
||||
Duration int32
|
||||
VideoSize int32
|
||||
}
|
||||
|
||||
type VideoInfo struct {
|
||||
Duration int32
|
||||
VideoSize int32
|
||||
}
|
||||
|
||||
// SendRequest 请求结构体
|
||||
|
||||
@@ -31,8 +31,8 @@ type WxSendVideoMsg struct {
|
||||
Unknown5 int32 `protobuf:"varint,5,opt,name=unknown5,proto3" json:"unknown5,omitempty"`
|
||||
Unknown6 int32 `protobuf:"varint,6,opt,name=unknown6,proto3" json:"unknown6,omitempty"`
|
||||
Unknown7 *VideoMsgExtra `protobuf:"bytes,7,opt,name=unknown7,proto3" json:"unknown7,omitempty"`
|
||||
Unknown8 int32 `protobuf:"varint,8,opt,name=unknown8,proto3" json:"unknown8,omitempty"`
|
||||
Unknown9 int32 `protobuf:"varint,9,opt,name=unknown9,proto3" json:"unknown9,omitempty"`
|
||||
VideoSize int32 `protobuf:"varint,8,opt,name=video_size,json=videoSize,proto3" json:"video_size,omitempty"`
|
||||
VideoSize2 int32 `protobuf:"varint,9,opt,name=video_size2,json=videoSize2,proto3" json:"video_size2,omitempty"`
|
||||
Unknown10 *VideoMsgExtra `protobuf:"bytes,10,opt,name=unknown10,proto3" json:"unknown10,omitempty"`
|
||||
Duration int32 `protobuf:"varint,11,opt,name=duration,proto3" json:"duration,omitempty"`
|
||||
Unknown12 int32 `protobuf:"varint,12,opt,name=unknown12,proto3" json:"unknown12,omitempty"`
|
||||
@@ -56,7 +56,7 @@ type WxSendVideoMsg struct {
|
||||
Md5Key2 []byte `protobuf:"bytes,48,opt,name=md5_key2,json=md5Key2,proto3" json:"md5_key2,omitempty"`
|
||||
CdnKey3 []byte `protobuf:"bytes,49,opt,name=cdn_key3,json=cdnKey3,proto3" json:"cdn_key3,omitempty"`
|
||||
AesKey3 []byte `protobuf:"bytes,50,opt,name=aes_key3,json=aesKey3,proto3" json:"aes_key3,omitempty"`
|
||||
Unknown51 int32 `protobuf:"varint,51,opt,name=unknown51,proto3" json:"unknown51,omitempty"`
|
||||
VideoSize3 int32 `protobuf:"varint,51,opt,name=video_size3,json=videoSize3,proto3" json:"video_size3,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
@@ -140,16 +140,16 @@ func (x *WxSendVideoMsg) GetUnknown7() *VideoMsgExtra {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *WxSendVideoMsg) GetUnknown8() int32 {
|
||||
func (x *WxSendVideoMsg) GetVideoSize() int32 {
|
||||
if x != nil {
|
||||
return x.Unknown8
|
||||
return x.VideoSize
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *WxSendVideoMsg) GetUnknown9() int32 {
|
||||
func (x *WxSendVideoMsg) GetVideoSize2() int32 {
|
||||
if x != nil {
|
||||
return x.Unknown9
|
||||
return x.VideoSize2
|
||||
}
|
||||
return 0
|
||||
}
|
||||
@@ -294,9 +294,9 @@ func (x *WxSendVideoMsg) GetAesKey3() []byte {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *WxSendVideoMsg) GetUnknown51() int32 {
|
||||
func (x *WxSendVideoMsg) GetVideoSize3() int32 {
|
||||
if x != nil {
|
||||
return x.Unknown51
|
||||
return x.VideoSize3
|
||||
}
|
||||
return 0
|
||||
}
|
||||
@@ -441,7 +441,7 @@ var File_proto_wxproto_video_msg_proto protoreflect.FileDescriptor
|
||||
|
||||
const file_proto_wxproto_video_msg_proto_rawDesc = "" +
|
||||
"\n" +
|
||||
"\x1dproto/wxproto/video_msg.proto\x12\awxproto\"\x9c\a\n" +
|
||||
"\x1dproto/wxproto/video_msg.proto\x12\awxproto\"\xa7\a\n" +
|
||||
"\x0eWxSendVideoMsg\x12/\n" +
|
||||
"\x06header\x18\x01 \x01(\v2\x17.wxproto.VideoMsgHeaderR\x06header\x12\"\n" +
|
||||
"\rclient_msg_id\x18\x02 \x01(\fR\vclientMsgId\x12\x16\n" +
|
||||
@@ -449,9 +449,11 @@ const file_proto_wxproto_video_msg_proto_rawDesc = "" +
|
||||
"\breceiver\x18\x04 \x01(\fR\breceiver\x12\x1a\n" +
|
||||
"\bunknown5\x18\x05 \x01(\x05R\bunknown5\x12\x1a\n" +
|
||||
"\bunknown6\x18\x06 \x01(\x05R\bunknown6\x122\n" +
|
||||
"\bunknown7\x18\a \x01(\v2\x16.wxproto.VideoMsgExtraR\bunknown7\x12\x1a\n" +
|
||||
"\bunknown8\x18\b \x01(\x05R\bunknown8\x12\x1a\n" +
|
||||
"\bunknown9\x18\t \x01(\x05R\bunknown9\x124\n" +
|
||||
"\bunknown7\x18\a \x01(\v2\x16.wxproto.VideoMsgExtraR\bunknown7\x12\x1d\n" +
|
||||
"\n" +
|
||||
"video_size\x18\b \x01(\x05R\tvideoSize\x12\x1f\n" +
|
||||
"\vvideo_size2\x18\t \x01(\x05R\n" +
|
||||
"videoSize2\x124\n" +
|
||||
"\tunknown10\x18\n" +
|
||||
" \x01(\v2\x16.wxproto.VideoMsgExtraR\tunknown10\x12\x1a\n" +
|
||||
"\bduration\x18\v \x01(\x05R\bduration\x12\x1c\n" +
|
||||
@@ -472,8 +474,9 @@ const file_proto_wxproto_video_msg_proto_rawDesc = "" +
|
||||
"\tunknown38\x18& \x01(\x05R\tunknown38\x12\x19\n" +
|
||||
"\bmd5_key2\x180 \x01(\fR\amd5Key2\x12\x19\n" +
|
||||
"\bcdn_key3\x181 \x01(\fR\acdnKey3\x12\x19\n" +
|
||||
"\baes_key3\x182 \x01(\fR\aaesKey3\x12\x1c\n" +
|
||||
"\tunknown51\x183 \x01(\x05R\tunknown51\"\xb1\x01\n" +
|
||||
"\baes_key3\x182 \x01(\fR\aaesKey3\x12\x1f\n" +
|
||||
"\vvideo_size3\x183 \x01(\x05R\n" +
|
||||
"videoSize3\"\xb1\x01\n" +
|
||||
"\x0eVideoMsgHeader\x12\x12\n" +
|
||||
"\x04flag\x18\x01 \x01(\fR\x04flag\x12\x15\n" +
|
||||
"\x06msg_id\x18\x02 \x01(\x03R\x05msgId\x12!\n" +
|
||||
|
||||
@@ -13,8 +13,8 @@ message WxSendVideoMsg {
|
||||
int32 unknown5 = 5;
|
||||
int32 unknown6 = 6;
|
||||
VideoMsgExtra unknown7 = 7;
|
||||
int32 unknown8 = 8;
|
||||
int32 unknown9 = 9;
|
||||
int32 video_size = 8;
|
||||
int32 video_size2 = 9;
|
||||
VideoMsgExtra unknown10 = 10;
|
||||
int32 duration = 11;
|
||||
int32 unknown12 = 12;
|
||||
@@ -38,7 +38,7 @@ message WxSendVideoMsg {
|
||||
bytes md5_key2 = 48;
|
||||
bytes cdn_key3 = 49;
|
||||
bytes aes_key3 = 50;
|
||||
int32 unknown51 = 51;
|
||||
int32 video_size3 = 51;
|
||||
}
|
||||
|
||||
message VideoMsgHeader {
|
||||
|
||||
@@ -13,7 +13,7 @@ import (
|
||||
)
|
||||
|
||||
// BuildVideoMsgProto 构建发送视频消息的protobuf并返回hex编码的字符串
|
||||
func BuildVideoMsgProto(sender, targetId, cdnKey, aesKey, md5Key, videoId string, duration int32) (string, error) {
|
||||
func BuildVideoMsgProto(sender, targetId, cdnKey, aesKey, md5Key, videoId string, duration int32, videoSize int32) (string, error) {
|
||||
// 生成16字节随机client_proof
|
||||
clientProof := make([]byte, 16)
|
||||
const chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
|
||||
@@ -54,8 +54,8 @@ func BuildVideoMsgProto(sender, targetId, cdnKey, aesKey, md5Key, videoId string
|
||||
Field1: 0,
|
||||
Field2: []byte{},
|
||||
},
|
||||
Unknown8: 1833320,
|
||||
Unknown9: 1833320,
|
||||
VideoSize: videoSize,
|
||||
VideoSize2: videoSize,
|
||||
Unknown10: &wxproto.VideoMsgExtra{
|
||||
Field1: 0,
|
||||
Field2: []byte{},
|
||||
@@ -77,9 +77,9 @@ func BuildVideoMsgProto(sender, targetId, cdnKey, aesKey, md5Key, videoId string
|
||||
VideoId: []byte(videoId),
|
||||
// Unknown38: 0, // 需要手动追加
|
||||
Md5Key2: []byte(md5Key),
|
||||
CdnKey3: []byte(cdnKey),
|
||||
AesKey3: []byte(aesKey),
|
||||
Unknown51: 1833320,
|
||||
CdnKey3: []byte(cdnKey),
|
||||
AesKey3: []byte(aesKey),
|
||||
VideoSize3: videoSize,
|
||||
}
|
||||
|
||||
data, err := proto.Marshal(msg)
|
||||
|
||||
+16
-8
@@ -6,6 +6,7 @@ import (
|
||||
"encoding/json"
|
||||
"encoding/xml"
|
||||
"errors"
|
||||
"os"
|
||||
"runtime/debug"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
@@ -96,32 +97,39 @@ func SendWechatMsg(m *SendMsg) {
|
||||
return
|
||||
}
|
||||
|
||||
// 获取视频时长
|
||||
// 获取视频时长和文件大小
|
||||
info := &VideoInfo{}
|
||||
duration, err := GetVideoDuration(targetPath)
|
||||
if err != nil {
|
||||
Error("获取视频时长失败", "err", err)
|
||||
} else {
|
||||
videoDurationMap.Store(targetId, duration)
|
||||
info.Duration = duration
|
||||
}
|
||||
if fi, err := os.Stat(targetPath); err == nil {
|
||||
info.VideoSize = int32(fi.Size())
|
||||
}
|
||||
videoInfoMap.Store(targetId, info)
|
||||
|
||||
result := fridaScript.ExportsCall("triggerUploadVideo", targetId, md5Str, targetPath)
|
||||
Info("📩 上传视频任务执行结果", "result", result, "target_id", targetId, "md5", md5Str, "path", targetPath, "duration", duration)
|
||||
Info("📩 上传视频任务执行结果", "result", result, "target_id", targetId, "md5", md5Str, "path", targetPath, "duration", info.Duration, "size", info.VideoSize)
|
||||
if result != "0" {
|
||||
Error("上传视频失败", "target_id", targetId, "md5", md5Str, "result", result)
|
||||
return
|
||||
}
|
||||
case "send_video":
|
||||
var duration int32
|
||||
if d, ok := videoDurationMap.LoadAndDelete(targetId); ok {
|
||||
duration = d.(int32)
|
||||
var duration, videoSize int32
|
||||
if info, ok := videoInfoMap.LoadAndDelete(targetId); ok {
|
||||
vi := info.(*VideoInfo)
|
||||
duration = vi.Duration
|
||||
videoSize = vi.VideoSize
|
||||
}
|
||||
protoHex, err := BuildVideoMsgProto(myWechatId, targetId, m.CdnKey, m.AesKey, m.Md5Key, m.VideoId, duration)
|
||||
protoHex, err := BuildVideoMsgProto(myWechatId, targetId, m.CdnKey, m.AesKey, m.Md5Key, m.VideoId, duration, videoSize)
|
||||
if err != nil {
|
||||
Error("构建视频protobuf失败", "err", err)
|
||||
return
|
||||
}
|
||||
result := fridaScript.ExportsCall("triggerSendVideoMessage", currTaskId, myWechatId, targetId, protoHex)
|
||||
Info("📩 发送视频任务执行结果", "result", result, "task_id", currTaskId, "wechat_id", myWechatId, "target_id", targetId, "duration", duration)
|
||||
Info("📩 发送视频任务执行结果", "result", result, "task_id", currTaskId, "wechat_id", myWechatId, "target_id", targetId, "duration", duration, "size", videoSize)
|
||||
if result != "1" {
|
||||
Error("发送视频失败", "task_id", currTaskId, "target_id", targetId, "result", result)
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user