Skip to content

Commit

Permalink
fix(123): adapt new file list api (close #3464)
Browse files Browse the repository at this point in the history
  • Loading branch information
xhofe committed Feb 16, 2023
1 parent 6ee4c10 commit 236c171
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions drivers/123/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -77,27 +78,31 @@ 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)
}, &resp)
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
}

0 comments on commit 236c171

Please sign in to comment.