github.com/fzfile/BaiduPCS-Go@v0.0.0-20200606205115-4408961cf336/internal/pcsfunctions/pcsdownload/pcsdownload.go (about) 1 package pcsdownload 2 3 import ( 4 "github.com/fzfile/BaiduPCS-Go/baidupcs" 5 "github.com/fzfile/BaiduPCS-Go/requester" 6 "net/http" 7 "strconv" 8 ) 9 10 // IsSkipMd5Checksum 是否忽略某些校验 11 func IsSkipMd5Checksum(size int64, md5Str string) bool { 12 switch { 13 case size == 1749504 && md5Str == "48bb9b0361dc9c672f3dc7b3ffcfde97": //8秒温馨提示 14 fallthrough 15 case size == 120 && md5Str == "6c1b84914588d09a6e5ec43605557457": //温馨提示文字版 16 return true 17 } 18 return false 19 } 20 21 // BaiduPCSURLCheckFunc downloader 首次检查下载地址要执行的函数 22 func BaiduPCSURLCheckFunc(client *requester.HTTPClient, durl string) (contentLength int64, resp *http.Response, err error) { 23 resp, err = client.Req(http.MethodGet, durl, nil, map[string]string{ 24 "Range": "bytes=0-" + strconv.FormatInt(baidupcs.MaxDownloadRangeSize-1, 10), 25 }) 26 if err != nil { 27 if resp != nil { 28 resp.Body.Close() 29 } 30 return 0, nil, err 31 } 32 33 contentLengthStr := resp.Header.Get("x-bs-file-size") 34 contentLength, _ = strconv.ParseInt(contentLengthStr, 10, 64) 35 return contentLength, resp, nil 36 }