🔒 fix baidu direct link

pull/548/head
Xhofe 2022-02-12 12:04:10 +08:00
parent 0814778a14
commit 5dca777caf
1 changed files with 4 additions and 4 deletions

View File

@ -140,13 +140,13 @@ func (driver Baidu) Link(args base.Args, account *model.Account) (*base.Link, er
return nil, err
}
u := fmt.Sprintf("%s&access_token=%s", resp.List[0].Dlink, account.AccessToken)
res, err := base.NoRedirectClient.R().Head(u)
res, err := base.NoRedirectClient.R().SetHeader("User-Agent", "pan.baidu.com").Head(u)
if err != nil {
return nil, err
}
if res.StatusCode() == 302 {
u = res.Header().Get("location")
}
//if res.StatusCode() == 302 {
u = res.Header().Get("location")
//}
return &base.Link{
Url: u,
Headers: []base.Header{