MCPcopy
hub / github.com/iuroc/bilidown / getWbiKeyRemote

Method getWbiKeyRemote

server/bilibili/client.go:87–116  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

85}
86
87func (client *BiliClient) getWbiKeyRemote() (wbiKey string, err error) {
88 if client.SESSDATA == "" {
89 return "", errors.New("SESSDATA 不能为空")
90 }
91 response, err := client.SimpleGET("https://api.bilibili.com/x/web-interface/nav", nil)
92 if err != nil {
93 return "", err
94 }
95 defer response.Body.Close()
96 body := BaseResV2{}
97 if err = json.NewDecoder(response.Body).Decode(&body); err != nil {
98 return "", err
99 }
100 var data struct {
101 WbiImg struct {
102 ImgURL string `json:"img_url"`
103 SubURL string `json:"sub_url"`
104 } `json:"wbi_img"`
105 }
106 if err = json.Unmarshal(body.Data, &data); err != nil {
107 return "", err
108 }
109 match := regexp.MustCompile(`/bfs/wbi/([a-z0-9]+)\.`)
110 imgKey := match.FindStringSubmatch(data.WbiImg.ImgURL)[1]
111 subKey := match.FindStringSubmatch(data.WbiImg.SubURL)[1]
112 if imgKey == "" || subKey == "" {
113 return "", errors.New("regexp.MustCompile(`/bfs/wbi/([a-z0-9])\\.`)")
114 }
115 return imgKey + subKey, nil
116}
117
118// GetQRStatus 获取二维码状态
119func (client *BiliClient) GetQRStatus(qrKey string) (qrStatus *QRStatus, sessdata string, err error) {

Callers 1

getWbiKeyMethod · 0.95

Calls 1

SimpleGETMethod · 0.95

Tested by

no test coverage detected