根据自定义内存上限调整下载方法

This commit is contained in:
itouakirai
2025-01-15 21:25:59 +08:00
parent eb929e3660
commit 8d071f7461
2 changed files with 31 additions and 24 deletions

View File

@@ -223,7 +223,7 @@ func extsong(b string)(bytes.Buffer){
progressbar.OptionShowCount(),
progressbar.OptionEnableColorCodes(true),
progressbar.OptionShowBytes(true),
//progressbar.OptionSetDescription("Downloading..."),
progressbar.OptionSetDescription("Downloading..."),
progressbar.OptionSetTheme(progressbar.Theme{
Saucer: "",
SaucerHead: "",
@@ -233,9 +233,6 @@ func extsong(b string)(bytes.Buffer){
}),
)
io.Copy(io.MultiWriter(&buffer, bar), resp.Body)
if err != nil {
fmt.Printf("读取文件失败: %v\n", err)
}
return buffer
}
func Run(adamId string, trackpath string, authtoken string, mutoken string)(error) {
@@ -271,8 +268,8 @@ func Run(adamId string, trackpath string, authtoken string, mutoken string)(erro
fmt.Println(err)
return err
}
fmt.Print("Downloading...\n")
body := extsong(fileurl)
fmt.Print("Downloaded\n")
//bodyReader := bytes.NewReader(body)
var buffer bytes.Buffer