From 16df225cb89d8cedfaa2184ac5195bf2095126b2 Mon Sep 17 00:00:00 2001 From: vclass <> Date: Tue, 23 Jul 2024 11:04:58 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BD=BF=E7=94=A8=E6=9B=B4=E7=A7=91=E5=AD=A6?= =?UTF-8?q?=E7=9A=84=E6=96=B9=E6=B3=95=E5=88=A4=E6=96=AD=E8=A7=86=E9=A2=91?= =?UTF-8?q?=E6=A0=BC=E5=BC=8F=EF=BC=8C=E7=9B=AE=E5=89=8DB=E7=AB=99?= =?UTF-8?q?=E5=8F=AA=E6=94=AF=E6=8C=81MP4=EF=BC=8C=E4=BB=A5=E9=98=B2?= =?UTF-8?q?=E4=B8=87=E4=B8=80=E5=8A=A0=E4=B8=8AFLV=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bobo/client/video.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/bobo/client/video.go b/bobo/client/video.go index 30a2cbc..3202ff1 100644 --- a/bobo/client/video.go +++ b/bobo/client/video.go @@ -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)