mirror of https://github.com/Xhofe/alist
fix(189pc): some minor issues
parent
2e91f5ffa5
commit
d31d49a9bb
|
@ -2,10 +2,9 @@ package _189
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"crypto/tls"
|
|
||||||
"encoding/json"
|
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/Xhofe/alist/utils"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/cookiejar"
|
"net/http/cookiejar"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
@ -33,7 +32,6 @@ func GetState(account *model.Account) *State {
|
||||||
return v
|
return v
|
||||||
}
|
}
|
||||||
state := &State{client: resty.New().
|
state := &State{client: resty.New().
|
||||||
SetProxy("http://192.168.0.30:8888").SetTLSClientConfig(&tls.Config{InsecureSkipVerify: true}).
|
|
||||||
SetHeaders(map[string]string{
|
SetHeaders(map[string]string{
|
||||||
"Accept": "application/json;charset=UTF-8",
|
"Accept": "application/json;charset=UTF-8",
|
||||||
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:74.0) Gecko/20100101 Firefox/76.0",
|
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:74.0) Gecko/20100101 Firefox/76.0",
|
||||||
|
@ -156,11 +154,10 @@ func (s *State) getLoginParam() (*LoginParam, error) {
|
||||||
"timeStamp": fmt.Sprint(timestamp()),
|
"timeStamp": fmt.Sprint(timestamp()),
|
||||||
}).
|
}).
|
||||||
Get(WEB_URL + "/api/portal/unifyLoginForPC.action")
|
Get(WEB_URL + "/api/portal/unifyLoginForPC.action")
|
||||||
log.Debug(res.String())
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
log.Debug(res.String())
|
||||||
param := &LoginParam{
|
param := &LoginParam{
|
||||||
CaptchaToken: regexp.MustCompile(`'captchaToken' value='(.+?)'`).FindStringSubmatch(res.String())[1],
|
CaptchaToken: regexp.MustCompile(`'captchaToken' value='(.+?)'`).FindStringSubmatch(res.String())[1],
|
||||||
Lt: regexp.MustCompile(`lt = "(.+?)"`).FindStringSubmatch(res.String())[1],
|
Lt: regexp.MustCompile(`lt = "(.+?)"`).FindStringSubmatch(res.String())[1],
|
||||||
|
@ -221,7 +218,7 @@ func (s *State) refreshSession(account *model.Account) error {
|
||||||
return s.login(account)
|
return s.login(account)
|
||||||
default:
|
default:
|
||||||
account.Status = userSessionResp.ResMessage
|
account.Status = userSessionResp.ResMessage
|
||||||
model.SaveAccount(account)
|
_ = model.SaveAccount(account)
|
||||||
return fmt.Errorf(userSessionResp.ResMessage)
|
return fmt.Errorf(userSessionResp.ResMessage)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
@ -296,7 +293,7 @@ func (s *State) Request(method string, fullUrl string, params url.Values, callba
|
||||||
log.Debug(res.String())
|
log.Debug(res.String())
|
||||||
|
|
||||||
var erron Erron
|
var erron Erron
|
||||||
json.Unmarshal(res.Body(), &erron)
|
utils.Json.Unmarshal(res.Body(), &erron)
|
||||||
if erron.ResCode != "" {
|
if erron.ResCode != "" {
|
||||||
return nil, fmt.Errorf(erron.ResMessage)
|
return nil, fmt.Errorf(erron.ResMessage)
|
||||||
}
|
}
|
||||||
|
|
|
@ -210,6 +210,9 @@ func (driver Cloud189) Files(path string, account *model.Account) ([]model.File,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if len(files) > 0 {
|
||||||
|
_ = base.SetCache(path, files, account)
|
||||||
|
}
|
||||||
return files, nil
|
return files, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue