MCPcopy Create free account
hub / github.com/LagrangeDev/LagrangeGo / UploadGroupVideo

Method UploadGroupVideo

client/richmedia.go:393–485  ·  view source on GitHub ↗
(groupUin uint32, video *message.ShortVideoElement)

Source from the content-addressed store, hash-verified

391}
392
393func (c *QQClient) UploadGroupVideo(groupUin uint32, video *message.ShortVideoElement) (*message.ShortVideoElement, error) {
394 if video == nil || video.Stream == nil {
395 return nil, errors.New("video is nil")
396 }
397 if video.Thumb == nil || video.Thumb.Stream == nil {
398 return nil, errors.New("video thumb is nil")
399 }
400 defer utils.CloseIO(video.Stream)
401 defer utils.CloseIO(video.Thumb.Stream)
402 req, err := oidb.BuildGroupVideoUploadReq(groupUin, video)
403 if err != nil {
404 return nil, err
405 }
406 resp, err := c.sendOidbPacketAndWait(req)
407 if err != nil {
408 return nil, err
409 }
410 uploadResp, err := oidb.ParseGroupVideoUploadResp(resp)
411 if err != nil {
412 return nil, err
413 }
414 ukey := uploadResp.Upload.UKey.Unwrap()
415 // video
416 if ukey != "" {
417 index := uploadResp.Upload.MsgInfo.MsgInfoBody[0].Index
418 extend := &highway.NTV2RichMediaHighwayExt{
419 FileUuid: index.FileUuid,
420 UKey: ukey,
421 Network: &highway.NTHighwayNetwork{
422 IPv4S: oidbIPv4ToNTHighwayIPv4(uploadResp.Upload.IPv4S),
423 },
424 MsgInfoBody: uploadResp.Upload.MsgInfo.MsgInfoBody,
425 BlockSize: uint32(highway2.BlockSize),
426 Hash: &highway.NTHighwayHash{
427 FileSha1: crypto.ComputeBlockSha1(video.Stream, highway2.BlockSize),
428 },
429 }
430 extStream, err := proto.Marshal(extend)
431 if err != nil {
432 return nil, err
433 }
434 md5, err := hex.DecodeString(index.Info.FileHash)
435 if err != nil {
436 return nil, err
437 }
438 err = c.highwayUpload(1005, video.Stream, uint64(video.Size), md5, extStream)
439 if err != nil {
440 return nil, err
441
442 }
443 }
444 // thumb
445 subFile := uploadResp.Upload.SubFileInfos[0]
446 if subFile.UKey != "" {
447 index := uploadResp.Upload.MsgInfo.MsgInfoBody[1].Index
448 sha1, err := hex.DecodeString(index.Info.FileSha1)
449 if err != nil {
450 return nil, err

Callers 2

UploadShortVideoMethod · 0.95

Calls 7

sendOidbPacketAndWaitMethod · 0.95
highwayUploadMethod · 0.95
CloseIOFunction · 0.92
ComputeBlockSha1Function · 0.92
MarshalFunction · 0.92
UnmarshalFunction · 0.92
oidbIPv4ToNTHighwayIPv4Function · 0.85

Tested by

no test coverage detected