From a90ef201c7d07de743a70461571ca9435d0e9b43 Mon Sep 17 00:00:00 2001 From: foxxorcat Date: Tue, 13 Sep 2022 18:44:07 +0800 Subject: [PATCH] fix(189pc,baidu_photo,thunder): single link limit multithreading --- drivers/189pc/driver.go | 21 ++++++++++----------- drivers/baidu_photo/utils.go | 9 ++++----- drivers/thunder/driver.go | 19 +++++++++---------- 3 files changed, 23 insertions(+), 26 deletions(-) diff --git a/drivers/189pc/driver.go b/drivers/189pc/driver.go index 11d32cca99d..c3bb08d6d32 100644 --- a/drivers/189pc/driver.go +++ b/drivers/189pc/driver.go @@ -3,8 +3,6 @@ package _189pc import ( "context" "net/http" - "regexp" - "strconv" "strings" "time" @@ -133,16 +131,17 @@ func (y *Yun189PC) Link(ctx context.Context, file model.Obj, args model.LinkArgs "User-Agent": []string{base.UserAgent}, }, } - - // 获取链接有效时常 - strs := regexp.MustCompile(`(?i)expire[^=]*=([0-9]*)`).FindStringSubmatch(downloadUrl.URL) - if len(strs) == 2 { - timestamp, err := strconv.ParseInt(strs[1], 10, 64) - if err == nil { - expired := time.Duration(timestamp-time.Now().Unix()) * time.Second - like.Expiration = &expired + /* + // 获取链接有效时常 + strs := regexp.MustCompile(`(?i)expire[^=]*=([0-9]*)`).FindStringSubmatch(downloadUrl.URL) + if len(strs) == 2 { + timestamp, err := strconv.ParseInt(strs[1], 10, 64) + if err == nil { + expired := time.Duration(timestamp-time.Now().Unix()) * time.Second + like.Expiration = &expired + } } - } + */ return like, nil } diff --git a/drivers/baidu_photo/utils.go b/drivers/baidu_photo/utils.go index c4bd216dcc1..48bffaa80f4 100644 --- a/drivers/baidu_photo/utils.go +++ b/drivers/baidu_photo/utils.go @@ -6,7 +6,6 @@ import ( "fmt" "net/http" "strings" - "time" "github.com/alist-org/alist/v3/drivers/base" "github.com/alist-org/alist/v3/internal/errs" @@ -329,13 +328,13 @@ func (d *BaiduPhoto) linkAlbum(ctx context.Context, file model.Obj, args model.L return nil, err } - exp := 8 * time.Hour + //exp := 8 * time.Hour link := &model.Link{ URL: res.Header().Get("location"), Header: http.Header{ "User-Agent": []string{headers["User-Agent"]}, }, - Expiration: &exp, + //Expiration: &exp, } return link, nil } @@ -365,13 +364,13 @@ func (d *BaiduPhoto) linkFile(ctx context.Context, file model.Obj, args model.Li return nil, err } - exp := 8 * time.Hour + //exp := 8 * time.Hour link := &model.Link{ URL: downloadUrl.Dlink, Header: http.Header{ "User-Agent": []string{headers["User-Agent"]}, }, - Expiration: &exp, + //Expiration: &exp, } return link, nil } diff --git a/drivers/thunder/driver.go b/drivers/thunder/driver.go index 2472ff7a5e4..89158f84909 100644 --- a/drivers/thunder/driver.go +++ b/drivers/thunder/driver.go @@ -4,10 +4,7 @@ import ( "context" "fmt" "net/http" - "regexp" - "strconv" "strings" - "time" "github.com/alist-org/alist/v3/drivers/base" "github.com/alist-org/alist/v3/internal/driver" @@ -255,14 +252,16 @@ func (xc *XunLeiCommon) Link(ctx context.Context, file model.Obj, args model.Lin }, } - strs := regexp.MustCompile(`e=([0-9]*)`).FindStringSubmatch(lFile.WebContentLink) - if len(strs) == 2 { - timestamp, err := strconv.ParseInt(strs[1], 10, 64) - if err == nil { - expired := time.Duration(timestamp-time.Now().Unix()) * time.Second - link.Expiration = &expired + /* + strs := regexp.MustCompile(`e=([0-9]*)`).FindStringSubmatch(lFile.WebContentLink) + if len(strs) == 2 { + timestamp, err := strconv.ParseInt(strs[1], 10, 64) + if err == nil { + expired := time.Duration(timestamp-time.Now().Unix()) * time.Second + link.Expiration = &expired + } } - } + */ return link, nil }