Skip to content

Commit

Permalink
fix(123): get download url (close #4244)
Browse files Browse the repository at this point in the history
  • Loading branch information
xhofe committed Apr 26, 2023
1 parent 36cd504 commit 9d55ad3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion drivers/123/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ func (d *Pan123) Link(ctx context.Context, file model.Obj, args model.LinkArgs)
}
}
u_ := u.String()
res, err := base.NoRedirectClient.R().SetQueryParamsFromValues(u.Query()).Head(u_)
log.Debug("download url: ", u_)
res, err := base.NoRedirectClient.R().Get(u_)
if err != nil {
return nil, err
}
Expand All @@ -108,6 +109,8 @@ func (d *Pan123) Link(ctx context.Context, file model.Obj, args model.LinkArgs)
log.Debugln("res code: ", res.StatusCode())
if res.StatusCode() == 302 {
link.URL = res.Header().Get("location")
} else if res.StatusCode() == 200 {
link.URL = utils.Json.Get(res.Body(), "data", "redirect_url").ToString()
}
return &link, nil
} else {
Expand Down
2 changes: 1 addition & 1 deletion drivers/123/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const (
SignIn = API + "/user/sign_in"
UserInfo = API + "/user/info"
FileList = API + "/file/list/new"
DownloadInfo = API + "/file/download_info"
DownloadInfo = "https://www.123pan.com/a/api/file/download_info"
Mkdir = API + "/file/upload_request"
Move = API + "/file/mod_pid"
Rename = API + "/file/rename"
Expand Down

0 comments on commit 9d55ad3

Please sign in to comment.