Skip to content

Commit

Permalink
fix: fix exceeding the paging size can not be displayed
Browse files Browse the repository at this point in the history
  • Loading branch information
52funny authored and 52funny committed Jul 16, 2024
1 parent 0c17ea9 commit 3052215
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 22 deletions.
1 change: 0 additions & 1 deletion internal/pikpak/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ func (p *PikPak) GetFolderFileStatList(parentId string) ([]FileStat, error) {
fileList := make([]FileStat, 0)

for {
// query.Add("filters", filters)
req, err := http.NewRequest("GET", "https://api-drive.mypikpak.com/drive/v1/files?"+query.Encode(), nil)
if err != nil {
return fileList, err
Expand Down
49 changes: 28 additions & 21 deletions internal/pikpak/folder.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,29 +49,36 @@ func (p *PikPak) GetFolderId(parentId string, dir string) (string, error) {
value.Add("with_audit", "false")
value.Add("thumbnail_size", "SIZE_LARGE")
value.Add("limit", "200")
req, err := http.NewRequest("GET", fmt.Sprintf("https://api-drive.mypikpak.com/drive/v1/files?"+value.Encode()), nil)
if err != nil {
return "", err
}
req.Header.Set("Country", "CN")
req.Header.Set("X-Peer-Id", p.DeviceId)
req.Header.Set("X-User-Region", "1")
req.Header.Set("X-Alt-Capability", "3")
req.Header.Set("X-Client-Version-Code", "10083")
req.Header.Set("X-Captcha-Token", p.CaptchaToken)
bs, err := p.sendRequest(req)
if err != nil {
return "", err
}
files := gjson.GetBytes(bs, "files").Array()
for {
req, err := http.NewRequest("GET", fmt.Sprintf("https://api-drive.mypikpak.com/drive/v1/files?"+value.Encode()), nil)
if err != nil {
return "", err
}
req.Header.Set("Country", "CN")
req.Header.Set("X-Peer-Id", p.DeviceId)
req.Header.Set("X-User-Region", "1")
req.Header.Set("X-Alt-Capability", "3")
req.Header.Set("X-Client-Version-Code", "10083")
req.Header.Set("X-Captcha-Token", p.CaptchaToken)
bs, err := p.sendRequest(req)
if err != nil {
return "", err
}
files := gjson.GetBytes(bs, "files").Array()

for _, file := range files {
kind := file.Get("kind").String()
name := file.Get("name").String()
trashed := file.Get("trashed").Bool()
if kind == "drive#folder" && name == dir && !trashed {
return file.Get("id").String(), nil
for _, file := range files {
kind := file.Get("kind").String()
name := file.Get("name").String()
trashed := file.Get("trashed").Bool()
if kind == "drive#folder" && name == dir && !trashed {
return file.Get("id").String(), nil
}
}
nextToken := gjson.GetBytes(bs, "next_page_token").String()
if nextToken == "" {
break
}
value.Set("page_token", nextToken)
}
return "", ErrNotFoundFolder
}
Expand Down

0 comments on commit 3052215

Please sign in to comment.