fix(123): get download url (close #4244)

pull/4263/head
Andy Hsu 2023-04-26 15:06:24 +08:00
parent 36cd504783
commit 9d55ad3af6
2 changed files with 5 additions and 2 deletions

View File

@ -97,7 +97,8 @@ func (d *Pan123) Link(ctx context.Context, file model.Obj, args model.LinkArgs)
} }
} }
u_ := u.String() 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 { if err != nil {
return nil, err return nil, err
} }
@ -108,6 +109,8 @@ func (d *Pan123) Link(ctx context.Context, file model.Obj, args model.LinkArgs)
log.Debugln("res code: ", res.StatusCode()) log.Debugln("res code: ", res.StatusCode())
if res.StatusCode() == 302 { if res.StatusCode() == 302 {
link.URL = res.Header().Get("location") 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 return &link, nil
} else { } else {

View File

@ -19,7 +19,7 @@ const (
SignIn = API + "/user/sign_in" SignIn = API + "/user/sign_in"
UserInfo = API + "/user/info" UserInfo = API + "/user/info"
FileList = API + "/file/list/new" 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" Mkdir = API + "/file/upload_request"
Move = API + "/file/mod_pid" Move = API + "/file/mod_pid"
Rename = API + "/file/rename" Rename = API + "/file/rename"