(groupUin uint32, video *message.ShortVideoElement)
| 391 | } |
| 392 | |
| 393 | func (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 |
no test coverage detected