From 236c17176cedb5e2f0655d5fefbe827f22f93527 Mon Sep 17 00:00:00 2001 From: Andy Hsu Date: Thu, 16 Feb 2023 22:09:33 +0800 Subject: [PATCH] fix(123): adapt new file list api (close #3464) --- drivers/123/util.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/123/util.go b/drivers/123/util.go index d509752f..ace6e5d2 100644 --- a/drivers/123/util.go +++ b/drivers/123/util.go @@ -4,6 +4,7 @@ import ( "errors" "fmt" "net/http" + "strconv" "github.com/alist-org/alist/v3/drivers/base" "github.com/alist-org/alist/v3/pkg/utils" @@ -77,18 +78,19 @@ func (d *Pan123) request(url string, method string, callback base.ReqCallback, r } func (d *Pan123) getFiles(parentId string) ([]File, error) { - next := "0" + page := 1 res := make([]File, 0) - for next != "-1" { + for { var resp Files query := map[string]string{ "driveId": "0", "limit": "100", - "next": next, + "next": "0", "orderBy": d.OrderBy, "orderDirection": d.OrderDirection, "parentFileId": parentId, "trashed": "false", + "Page": strconv.Itoa(page), } _, err := d.request("https://www.123pan.com/api/file/list/new", http.MethodGet, func(req *resty.Request) { req.SetQueryParams(query) @@ -96,8 +98,11 @@ func (d *Pan123) getFiles(parentId string) ([]File, error) { if err != nil { return nil, err } - next = resp.Data.Next + page++ res = append(res, resp.Data.InfoList...) + if len(resp.Data.InfoList) == 0 || resp.Data.Next == "-1" { + break + } } return res, nil }