Compare commits

...

5 Commits

Author SHA1 Message Date
j2rong4cn 101f4a2434 Merge remote-tracking branch 'upstream/main' into deps/resty-v3 2025-07-04 14:30:40 +08:00
j2rong4cn 4990af3c09 fix 139yun 2025-07-04 14:27:10 +08:00
foxxorcat 82619cc9b2 chore(mopan,weiyun): resty update 2025-07-03 22:36:56 +08:00
j2rong4cn 9b69d8e3c4 115 2025-07-03 21:37:24 +08:00
j2rong4cn a73b345749 chore(deps): use resty.dev/v3 2025-07-03 21:19:55 +08:00
106 changed files with 288 additions and 355 deletions
+3 -3
View File
@@ -9,7 +9,7 @@ import (
"github.com/OpenListTeam/OpenList/v4/internal/op"
"github.com/OpenListTeam/OpenList/v4/internal/setting"
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
"github.com/go-resty/resty/v2"
"resty.dev/v3"
)
func DelAdminCacheOnline() {
@@ -42,8 +42,8 @@ func DelUserCacheOnline(username string) {
utils.Log.Warnf("[del_user_cache_online] failed: %+v", res.String())
return
}
code := utils.Json.Get(res.Body(), "code").ToInt()
msg := utils.Json.Get(res.Body(), "message").ToString()
code := utils.Json.Get(res.Bytes(), "code").ToInt()
msg := utils.Json.Get(res.Bytes(), "message").ToString()
if code != 200 {
utils.Log.Errorf("[del_user_cache_online] error: %s", msg)
return
+1 -1
View File
@@ -2,7 +2,7 @@ package _115
import (
"github.com/OpenListTeam/OpenList/v4/drivers/base"
driver115 "github.com/SheltonZhu/115driver/pkg/driver"
driver115 "github.com/j2rong4cn/115driver/pkg/driver"
log "github.com/sirupsen/logrus"
)
+2 -2
View File
@@ -10,7 +10,7 @@ import (
streamPkg "github.com/OpenListTeam/OpenList/v4/internal/stream"
"github.com/OpenListTeam/OpenList/v4/pkg/http_range"
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
driver115 "github.com/SheltonZhu/115driver/pkg/driver"
driver115 "github.com/j2rong4cn/115driver/pkg/driver"
"github.com/pkg/errors"
"golang.org/x/time/rate"
)
@@ -93,7 +93,7 @@ func (d *Pan115) MakeDir(ctx context.Context, parentDir model.Obj, dirName strin
req := d.client.NewRequest().
SetFormData(form).
SetResult(&result).
ForceContentType("application/json;charset=UTF-8")
SetForceResponseContentType("application/json;charset=UTF-8")
resp, err := req.Post(driver115.ApiDirAdd)
+1 -1
View File
@@ -5,7 +5,7 @@ import (
"github.com/OpenListTeam/OpenList/v4/internal/model"
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
"github.com/SheltonZhu/115driver/pkg/driver"
"github.com/j2rong4cn/115driver/pkg/driver"
)
var _ model.Obj = (*FileObj)(nil)
+6 -6
View File
@@ -24,9 +24,9 @@ import (
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
"github.com/aliyun/aliyun-oss-go-sdk/oss"
cipher "github.com/SheltonZhu/115driver/pkg/crypto/ec115"
crypto "github.com/SheltonZhu/115driver/pkg/crypto/m115"
driver115 "github.com/SheltonZhu/115driver/pkg/driver"
cipher "github.com/j2rong4cn/115driver/pkg/crypto/ec115"
crypto "github.com/j2rong4cn/115driver/pkg/crypto/m115"
driver115 "github.com/j2rong4cn/115driver/pkg/driver"
"github.com/pkg/errors"
)
@@ -88,7 +88,7 @@ func (d *Pan115) getNewFileByPickCode(pickCode string) (*FileObj, error) {
result := driver115.GetFileInfoResponse{}
req := d.client.NewRequest().
SetQueryParam("pick_code", pickCode).
ForceContentType("application/json;charset=UTF-8").
SetForceResponseContentType("application/json;charset=UTF-8").
SetResult(&result)
resp, err := req.Get(driver115.ApiFileInfo)
if err := driver115.CheckErr(err, &result, resp); err != nil {
@@ -125,7 +125,7 @@ func (d *Pan115) DownloadWithUA(pickCode, ua string) (*driver115.DownloadInfo, e
req.Header.Set("Cookie", d.Cookie)
req.Header.Set("User-Agent", ua)
resp, err := d.client.Client.GetClient().Do(req)
resp, err := d.client.Client.Client().Do(req)
if err != nil {
return nil, err
}
@@ -227,7 +227,7 @@ func (d *Pan115) rapidUpload(fileSize int64, fileName, dirID, preID, fileID stri
if err != nil {
return nil, err
}
data := resp.RawBody()
data := resp.Body
defer data.Close()
if bodyBytes, err = io.ReadAll(data); err != nil {
return nil, err
+1 -1
View File
@@ -7,7 +7,7 @@ import (
"github.com/OpenListTeam/OpenList/v4/internal/errs"
"github.com/OpenListTeam/OpenList/v4/internal/model"
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
driver115 "github.com/SheltonZhu/115driver/pkg/driver"
driver115 "github.com/j2rong4cn/115driver/pkg/driver"
"golang.org/x/time/rate"
)
+1 -1
View File
@@ -7,7 +7,7 @@ import (
"github.com/OpenListTeam/OpenList/v4/internal/model"
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
driver115 "github.com/SheltonZhu/115driver/pkg/driver"
driver115 "github.com/j2rong4cn/115driver/pkg/driver"
"github.com/pkg/errors"
)
+2 -2
View File
@@ -22,8 +22,8 @@ import (
"github.com/aws/aws-sdk-go/aws/credentials"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/s3/s3manager"
"github.com/go-resty/resty/v2"
log "github.com/sirupsen/logrus"
"resty.dev/v3"
)
type Pan123 struct {
@@ -115,7 +115,7 @@ func (d *Pan123) Link(ctx context.Context, file model.Obj, args model.LinkArgs)
if res.StatusCode() == 302 {
link.URL = res.Header().Get("location")
} else if res.StatusCode() < 300 {
link.URL = utils.Json.Get(res.Body(), "data", "redirect_url").ToString()
link.URL = utils.Json.Get(res.Bytes(), "data", "redirect_url").ToString()
}
link.Header = http.Header{
"Referer": []string{"https://www.123pan.com/"},
+1 -1
View File
@@ -11,7 +11,7 @@ import (
"github.com/OpenListTeam/OpenList/v4/internal/driver"
"github.com/OpenListTeam/OpenList/v4/internal/model"
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
"github.com/go-resty/resty/v2"
"resty.dev/v3"
)
func (d *Pan123) getS3PreSignedUrls(ctx context.Context, upReq *UploadResp, start, end int) (*S3PreSignedURLs, error) {
+5 -5
View File
@@ -15,9 +15,9 @@ import (
"github.com/OpenListTeam/OpenList/v4/drivers/base"
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
"github.com/go-resty/resty/v2"
jsoniter "github.com/json-iterator/go"
log "github.com/sirupsen/logrus"
"resty.dev/v3"
)
// do others that not defined in Driver interface
@@ -172,10 +172,10 @@ func (d *Pan123) login() error {
if err != nil {
return err
}
if utils.Json.Get(res.Body(), "code").ToInt() != 200 {
err = fmt.Errorf(utils.Json.Get(res.Body(), "message").ToString())
if utils.Json.Get(res.Bytes(), "code").ToInt() != 200 {
err = fmt.Errorf(utils.Json.Get(res.Bytes(), "message").ToString())
} else {
d.AccessToken = utils.Json.Get(res.Body(), "data", "token").ToString()
d.AccessToken = utils.Json.Get(res.Bytes(), "data", "token").ToString()
}
return err
}
@@ -222,7 +222,7 @@ do:
if err != nil {
return nil, err
}
body := res.Body()
body := res.Bytes()
code := utils.Json.Get(body, "code").ToInt()
if code != 0 {
if !isRetry && code == 401 {
+1 -1
View File
@@ -13,7 +13,7 @@ import (
"github.com/OpenListTeam/OpenList/v4/pkg/http_range"
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
"github.com/avast/retry-go"
"github.com/go-resty/resty/v2"
"resty.dev/v3"
)
func (d *Open123) create(parentFileID int64, filename string, etag string, size int64, duplicate int, containDir bool) (*UploadCreateResp, error) {
+2 -2
View File
@@ -9,8 +9,8 @@ import (
"github.com/OpenListTeam/OpenList/v4/drivers/base"
"github.com/OpenListTeam/OpenList/v4/internal/op"
"github.com/go-resty/resty/v2"
log "github.com/sirupsen/logrus"
"resty.dev/v3"
)
var ( //不同情况下获取的AccessTokenQPS限制不同 如下模块化易于拓展
@@ -56,7 +56,7 @@ func (d *Open123) Request(apiInfo *ApiInfo, method string, callback base.ReqCall
if err != nil {
return nil, err
}
body := res.Body()
body := res.Bytes()
// 解析为通用响应
var baseResp BaseResp
+2 -2
View File
@@ -17,8 +17,8 @@ import (
"github.com/OpenListTeam/OpenList/v4/internal/errs"
"github.com/OpenListTeam/OpenList/v4/internal/model"
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
"github.com/go-resty/resty/v2"
log "github.com/sirupsen/logrus"
"resty.dev/v3"
)
type Pan123Share struct {
@@ -119,7 +119,7 @@ func (d *Pan123Share) Link(ctx context.Context, file model.Obj, args model.LinkA
if res.StatusCode() == 302 {
link.URL = res.Header().Get("location")
} else if res.StatusCode() < 300 {
link.URL = utils.Json.Get(res.Body(), "data", "redirect_url").ToString()
link.URL = utils.Json.Get(res.Bytes(), "data", "redirect_url").ToString()
}
link.Header = http.Header{
"Referer": []string{"https://www.123pan.com/"},
+2 -2
View File
@@ -15,8 +15,8 @@ import (
"github.com/OpenListTeam/OpenList/v4/drivers/base"
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
"github.com/go-resty/resty/v2"
jsoniter "github.com/json-iterator/go"
"resty.dev/v3"
)
const (
@@ -76,7 +76,7 @@ func (d *Pan123Share) request(url string, method string, callback base.ReqCallba
if err != nil {
return nil, err
}
body := res.Body()
body := res.Bytes()
code := utils.Json.Get(body, "code").ToInt()
if code != 0 {
return nil, errors.New(jsoniter.Get(body, "message").ToString())
+2 -4
View File
@@ -286,10 +286,8 @@ type PersonalUploadUrlResp struct {
}
type QueryRoutePolicyResp struct {
Success bool `json:"success"`
Code string `json:"code"`
Message string `json:"message"`
Data struct {
BaseResp
Data struct {
RoutePolicyList []struct {
SiteID string `json:"siteID"`
SiteCode string `json:"siteCode"`
+23 -24
View File
@@ -17,9 +17,9 @@ import (
"github.com/OpenListTeam/OpenList/v4/internal/op"
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
"github.com/OpenListTeam/OpenList/v4/pkg/utils/random"
"github.com/go-resty/resty/v2"
jsoniter "github.com/json-iterator/go"
log "github.com/sirupsen/logrus"
"resty.dev/v3"
)
// do others that not defined in Driver interface
@@ -89,7 +89,7 @@ func (d *Yun139) refreshToken() error {
var resp RefreshTokenResp
reqBody := "<root><token>" + splits[2] + "</token><account>" + splits[1] + "</account><clienttype>656</clienttype></root>"
_, err = base.RestyClient.R().
ForceContentType("application/xml").
SetForceResponseContentType("application/xml").
SetBody(reqBody).
SetResult(&resp).
Post(url)
@@ -150,29 +150,24 @@ func (d *Yun139) request(pathname string, method string, callback base.ReqCallba
return nil, errors.New(e.Message)
}
if resp != nil {
err = utils.Json.Unmarshal(res.Body(), resp)
err = utils.Json.Unmarshal(res.Bytes(), resp)
if err != nil {
return nil, err
}
}
return res.Body(), nil
return res.Bytes(), nil
}
func (d *Yun139) requestRoute(data interface{}, resp interface{}) ([]byte, error) {
body, err := utils.Json.Marshal(data)
if err != nil {
return nil, err
}
url := "https://user-njs.yun.139.com/user/route/qryRoutePolicy"
req := base.RestyClient.R()
randStr := random.String(16)
ts := time.Now().Format("2006-01-02 15:04:05")
callback := func(req *resty.Request) {
req.SetBody(data)
}
if callback != nil {
callback(req)
}
body, err := utils.Json.Marshal(req.Body)
if err != nil {
return nil, err
}
req.SetBody(data)
sign := calSign(string(body), ts, randStr)
svcType := "1"
if d.isFamily() {
@@ -199,20 +194,24 @@ func (d *Yun139) requestRoute(data interface{}, resp interface{}) ([]byte, error
"Inner-Hcy-Router-Https": "1",
})
var e BaseResp
req.SetResult(&e)
res, err := req.Execute(http.MethodPost, url)
if err != nil {
return nil, err
}
log.Debugln(res.String())
var e BaseResp
err = utils.Json.Unmarshal(res.Bytes(), &e)
if err != nil {
return nil, err
}
if !e.Success {
return nil, errors.New(e.Message)
}
if resp != nil {
err = utils.Json.Unmarshal(res.Body(), resp)
if err != nil {
return nil, err
}
err = utils.Json.Unmarshal(res.Bytes(), resp)
if err != nil {
return nil, err
}
return res.Body(), nil
return res.Bytes(), err
}
func (d *Yun139) post(pathname string, data interface{}, resp interface{}) ([]byte, error) {
@@ -500,12 +499,12 @@ func (d *Yun139) personalRequest(pathname string, method string, callback base.R
return nil, errors.New(e.Message)
}
if resp != nil {
err = utils.Json.Unmarshal(res.Body(), resp)
err = utils.Json.Unmarshal(res.Bytes(), resp)
if err != nil {
return nil, err
}
}
return res.Body(), nil
return res.Bytes(), nil
}
func (d *Yun139) personalPost(pathname string, data interface{}, resp interface{}) ([]byte, error) {
return d.personalRequest(pathname, http.MethodPost, func(req *resty.Request) {
+2 -2
View File
@@ -9,8 +9,8 @@ import (
"github.com/OpenListTeam/OpenList/v4/internal/driver"
"github.com/OpenListTeam/OpenList/v4/internal/model"
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
"github.com/go-resty/resty/v2"
log "github.com/sirupsen/logrus"
"resty.dev/v3"
)
type Cloud189 struct {
@@ -52,7 +52,7 @@ func (d *Cloud189) Link(ctx context.Context, file model.Obj, args model.LinkArgs
if err != nil {
return nil, err
}
client := resty.NewWithClient(d.client.GetClient()).SetRedirectPolicy(
client := resty.NewWithClient(d.client.Client()).SetRedirectPolicy(
resty.RedirectPolicyFunc(func(req *http.Request, via []*http.Request) error {
return http.ErrUseLastResponse
}))
+3 -3
View File
@@ -83,7 +83,7 @@ func (d *Cloud189) newLogin() error {
if err != nil {
return err
}
err = utils.Json.Unmarshal(res.Body(), &encryptConf)
err = utils.Json.Unmarshal(res.Bytes(), &encryptConf)
if err != nil {
return err
}
@@ -118,9 +118,9 @@ func (d *Cloud189) newLogin() error {
return err
}
log.Debugf("189 login resp body: %s", res.String())
loginResult := utils.Json.Get(res.Body(), "result").ToInt()
loginResult := utils.Json.Get(res.Bytes(), "result").ToInt()
if loginResult != 0 {
return errors.New(utils.Json.Get(res.Body(), "msg").ToString())
return errors.New(utils.Json.Get(res.Bytes(), "msg").ToString())
}
return nil
}
+12 -12
View File
@@ -20,9 +20,9 @@ import (
"github.com/OpenListTeam/OpenList/v4/internal/model"
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
myrand "github.com/OpenListTeam/OpenList/v4/pkg/utils/random"
"github.com/go-resty/resty/v2"
jsoniter "github.com/json-iterator/go"
log "github.com/sirupsen/logrus"
"resty.dev/v3"
)
// do others that not defined in Driver interface
@@ -81,7 +81,7 @@ import (
// // Enter the verification code manually
// //err = message.GetMessenger().WaitSend(message.Message{
// // Type: "image",
// // Content: "data:image/png;base64," + base64.StdEncoding.EncodeToString(imgRes.Body()),
// // Content: "data:image/png;base64," + base64.StdEncoding.EncodeToString(imgRes.Body),
// //}, 10)
// //if err != nil {
// // return err
@@ -89,15 +89,15 @@ import (
// //vCodeRS, err = message.GetMessenger().WaitReceive(30)
// // use ocr api
// vRes, err := base.RestyClient.R().SetMultipartField(
// "image", "validateCode.png", "image/png", bytes.NewReader(imgRes.Body())).
// "image", "validateCode.png", "image/png", bytes.NewReader(imgRes.Body)).
// Post(setting.GetStr(conf.OcrApi))
// if err != nil {
// return err
// }
// if jsoniter.Get(vRes.Body(), "status").ToInt() != 200 {
// return errors.New("ocr error:" + jsoniter.Get(vRes.Body(), "msg").ToString())
// if jsoniter.Get(vRes.Bytes(), "status").ToInt() != 200 {
// return errors.New("ocr error:" + jsoniter.Get(vRes.Bytes(), "msg").ToString())
// }
// vCodeRS = jsoniter.Get(vRes.Body(), "result").ToString()
// vCodeRS = jsoniter.Get(vRes.Bytes(), "result").ToString()
// log.Debugln("code: ", vCodeRS)
// }
// userRsa := RsaEncode([]byte(d.Username), jRsakey, true)
@@ -128,7 +128,7 @@ import (
// if err != nil {
// return err
// }
// err = utils.Json.Unmarshal(res.Body(), &loginResp)
// err = utils.Json.Unmarshal(res.Bytes(), &loginResp)
// if err != nil {
// log.Error(err.Error())
// return err
@@ -167,10 +167,10 @@ func (d *Cloud189) request(url string, method string, callback base.ReqCallback,
return d.request(url, method, callback, resp)
}
}
if jsoniter.Get(res.Body(), "res_code").ToInt() != 0 {
err = errors.New(jsoniter.Get(res.Body(), "res_message").ToString())
if jsoniter.Get(res.Bytes(), "res_code").ToInt() != 0 {
err = errors.New(jsoniter.Get(res.Bytes(), "res_message").ToString())
}
return res.Body(), err
return res.Bytes(), err
}
func (d *Cloud189) getFiles(fileId string) ([]model.Obj, error) {
@@ -232,7 +232,7 @@ func (d *Cloud189) oldUpload(dstDir model.Obj, file model.FileStreamer) error {
if err != nil {
return err
}
if utils.Json.Get(res.Body(), "MD5").ToString() != "" {
if utils.Json.Get(res.Bytes(), "MD5").ToString() != "" {
return nil
}
log.Debugf(res.String())
@@ -297,7 +297,7 @@ func (d *Cloud189) uploadRequest(uri string, form map[string]string, resp interf
if err != nil {
return nil, err
}
data = res.Body()
data = res.Bytes()
if utils.Json.Get(data, "code").ToString() != "SUCCESS" {
return nil, errors.New(uri + "---" + jsoniter.Get(data, "msg").ToString())
}
+2 -2
View File
@@ -12,7 +12,7 @@ import (
"github.com/OpenListTeam/OpenList/v4/internal/driver"
"github.com/OpenListTeam/OpenList/v4/internal/errs"
"github.com/OpenListTeam/OpenList/v4/internal/model"
"github.com/go-resty/resty/v2"
"resty.dev/v3"
)
type Cloud189TV struct {
@@ -126,7 +126,7 @@ func (y *Cloud189TV) Link(ctx context.Context, file model.Obj, args model.LinkAr
if err != nil {
return nil, err
}
defer res.RawBody().Close()
defer res.Body.Close()
if res.StatusCode() == 302 {
downloadUrl.URL = res.Header().Get("location")
}

Some files were not shown because too many files have changed in this diff Show More