Przeglądaj źródła

bilimusic功能基本完成

JamZYM 8 miesięcy temu
rodzic
commit
69d0bef642
1 zmienionych plików z 6 dodań i 3 usunięć
  1. 6 3
      main.go

+ 6 - 3
main.go

@@ -6,6 +6,7 @@ import (
 	"io"
 	"log"
 	"net/http"
+	"net/url"
 	"os"
 	"strings"
 
@@ -51,8 +52,10 @@ func msgProccess(msg map[string]interface{}, connBot api.WsBot) {
 					fmt.Println("http://" + os.Getenv("HOST") + ":" + os.Getenv("BVDLPORT") + "/api/download?bv=" + bv + "&title=" + title)
 					// result, err := http.PostForm("http://"+os.Getenv("HOST")+":"+os.Getenv("BVDLPORT")+"/api/download?bv="+bv+"&title="+title, nil)
 
-					url := "http://" + os.Getenv("HOST") + ":" + os.Getenv("BVDLPORT") + "/api/download?bv=" + bv + "&title=" + title
-					result, err := http.Get(url)
+					qbv := url.QueryEscape(bv)
+					qtitle := url.QueryEscape(title)
+					geturl := "http://" + os.Getenv("HOST") + ":" + os.Getenv("BVDLPORT") + "/api/download?bv=" + qbv + "&title=" + qtitle
+					result, err := http.Get(geturl)
 
 					// url := "http://" + os.Getenv("HOST") + ":" + os.Getenv("BVDLPORT") + "/api/download"
 					// body := fmt.Sprintf(`{"bv":"%s","title":"%s"}`, bv, title)
@@ -62,7 +65,7 @@ func msgProccess(msg map[string]interface{}, connBot api.WsBot) {
 						connBot.Send_private_msg(user_id, "下载失败")
 						fmt.Println(err)
 					} else {
-						fmt.Print(result)
+						fmt.Print(result.Body)
 						connBot.Send_private_msg(user_id, title)
 					}