Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 36 additions & 18 deletions drivers/lanzou/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,25 +157,43 @@ func (d *LanZou) request(url string, method string, callback base.ReqCallback, u
}

func (d *LanZou) Login() ([]*http.Cookie, error) {
resp, err := base.NewRestyClient().SetRedirectPolicy(resty.NoRedirectPolicy()).
R().SetFormData(map[string]string{
"task": "3",
"uid": d.Account,
"pwd": d.Password,
"setSessionId": "",
"setSig": "",
"setScene": "",
"setTocen": "",
"formhash": "",
}).Post("https://up.woozooo.com/mlogin.php")
if err != nil {
return nil, err
}
if utils.Json.Get(resp.Body(), "zt").ToInt() != 1 {
return nil, fmt.Errorf("login err: %s", resp.Body())
var vs string
for retry := 0; retry < 3; retry++ {
Comment thread
PIKACHUIM marked this conversation as resolved.
req := base.NewRestyClient().SetRedirectPolicy(resty.NoRedirectPolicy()).R()

// 如果已计算出 acw_sc__v2,通过 cookie 携带
if vs != "" {
req.SetHeader("cookie", "acw_sc__v2="+vs)
}

resp, err := req.SetFormData(map[string]string{
"task": "3",
"uid": d.Account,
"pwd": d.Password,
"setSessionId": "",
"setSig": "",
"setScene": "",
"setTocen": "",
"formhash": "",
}).Post("https://up.woozooo.com/mlogin.php")
if err != nil {
return nil, err
}
bodyStr := resp.String()
if strings.Contains(bodyStr, "acw_sc__v2") {
vs, err = CalcAcwScV2(bodyStr)
if err != nil {
return nil, err
Comment thread
PIKACHUIM marked this conversation as resolved.
}
continue
}
if utils.Json.Get(resp.Body(), "zt").ToInt() != 1 {
return nil, fmt.Errorf("login err: %s", resp.Body())
}
d.Cookie = CookieToString(resp.Cookies())
return resp.Cookies(), nil
}
d.Cookie = CookieToString(resp.Cookies())
return resp.Cookies(), nil
return nil, errors.New("acw_sc__v2 validation error")
}

/*
Expand Down