1
0
mirror of https://github.com/Mrs4s/go-cqhttp.git synced 2025-05-07 20:45:53 +08:00

fix thumb.

This commit is contained in:
Mrs4s 2021-01-11 00:50:50 +08:00
parent 50f0f572bc
commit eaec0e545f
2 changed files with 8 additions and 4 deletions

View File

@ -1021,10 +1021,12 @@ video:
b, _ := ioutil.ReadFile(rawPath)
r := binary.NewReader(b)
return &LocalVideoElement{ShortVideoElement: message.ShortVideoElement{ // todo 检查缓存是否有效
Md5: r.ReadBytes(16),
Size: r.ReadInt32(),
Name: r.ReadString(),
Uuid: r.ReadAvailable(),
Md5: r.ReadBytes(16),
ThumbMd5: r.ReadBytes(16),
Size: r.ReadInt32(),
ThumbSize: r.ReadInt32(),
Name: r.ReadString(),
Uuid: r.ReadAvailable(),
}}, nil
} else {
return &LocalVideoElement{File: rawPath}, nil

View File

@ -566,7 +566,9 @@ func (bot *CQBot) checkMedia(e []message.IMessageElement) {
if !global.PathExists(path.Join(global.VIDEO_PATH, filename)) {
_ = ioutil.WriteFile(path.Join(global.VIDEO_PATH, filename), binary.NewWriterF(func(w *binary.Writer) {
w.Write(i.Md5)
w.Write(i.ThumbMd5)
w.WriteUInt32(uint32(i.Size))
w.WriteUInt32(uint32(i.ThumbSize))
w.WriteString(i.Name)
w.Write(i.Uuid)
}), 0644)