mirror of https://github.com/Xhofe/alist
fix(123): get download url (close #4244)
parent
36cd504783
commit
9d55ad3af6
|
@ -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 {
|
||||||
|
|
|
@ -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"
|
||||||
|
|
Loading…
Reference in New Issue