Skip to content

Commit da84a80

Browse files
author
hcrgm
authored
feat(baidu): support link cache lasting one hour (#2033)
1 parent b05a51a commit da84a80

3 files changed

Lines changed: 6 additions & 1 deletion

File tree

‎drivers/baidu_netdisk/util.go‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,11 +215,13 @@ func (d *BaiduNetdisk) linkOfficial(file model.Obj, _ model.LinkArgs) (*model.Li
215215
u = res.Header().Get("location")
216216
//}
217217

218+
exp := time.Hour
218219
return &model.Link{
219220
URL: u,
220221
Header: http.Header{
221222
"User-Agent": []string{"pan.baidu.com"},
222223
},
224+
Expiration: &exp,
223225
}, nil
224226
}
225227

‎drivers/baidu_photo/types.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ func (c *File) Thumb() string {
7272
}
7373

7474
func (c *File) GetHash() utils.HashInfo {
75-
return utils.NewHashInfo(utils.MD5, DecryptMd5(c.Md5))
75+
return utils.HashInfo{}
7676
}
7777

7878
/*相册部分*/

‎drivers/baidu_photo/utils.go‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"net/http"
88
"strconv"
99
"strings"
10+
"time"
1011
"unicode"
1112

1213
"github.com/OpenListTeam/OpenList/v4/drivers/base"
@@ -411,12 +412,14 @@ func (d *BaiduPhoto) linkFile(ctx context.Context, file *File, args model.LinkAr
411412
// }
412413

413414
// location := resp.Header().Get("Location")
415+
exp := time.Hour
414416
link := &model.Link{
415417
URL: downloadUrl.Dlink,
416418
Header: http.Header{
417419
"User-Agent": []string{headers["User-Agent"]},
418420
"Referer": []string{"https://photo.baidu.com/"},
419421
},
422+
Expiration: &exp,
420423
}
421424
return link, nil
422425
}

0 commit comments

Comments
 (0)