Skip to content

Commit

Permalink
Merge branch 'hotfix/0.5.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
vclass committed Jul 23, 2024
2 parents 6f07b1a + 16df225 commit fb90dc9
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions bobo/client/video.go
Original file line number Diff line number Diff line change
Expand Up @@ -775,13 +775,19 @@ func (c *Client) DownloadVideoBestByBvidCid(cid int, bvid, filePath, fileName st
if stream == nil || stream.Video == nil {
return "", "", errors.New("无可用视频流")
}
mineTypeInfo := strings.Split(stream.Video.MimeType, "/")
if len(mineTypeInfo) < 2 {

mimeType := ""
sMimeType := strings.ToUpper(stream.Video.MimeType)
if strings.Contains(sMimeType, "MP4") {
mimeType = "mp4"
} else if strings.Contains(sMimeType, "FLV") {
mimeType = "flv"
} else {
msg := fmt.Sprintf("视频Bvid:[%s],无法获取视频类型:[%s]", bvid, stream.Video.MimeType)
logger.Error(msg)
return "", "", errors.New(msg)
}
mimeType := mineTypeInfo[1]

targetName := fmt.Sprintf("%s.%s", fileName, mimeType)
videoPath := filepath.Join(filePath, targetName)

Expand Down

0 comments on commit fb90dc9

Please sign in to comment.