Skip to content

Commit

Permalink
fix(189pc,baidu_photo,thunder): single link limit multithreading
Browse files Browse the repository at this point in the history
  • Loading branch information
foxxorcat committed Sep 13, 2022
1 parent 2de0da8 commit a90ef20
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 26 deletions.
21 changes: 10 additions & 11 deletions drivers/189pc/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ package _189pc
import (
"context"
"net/http"
"regexp"
"strconv"
"strings"
"time"

Expand Down Expand Up @@ -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
}

Expand Down
9 changes: 4 additions & 5 deletions drivers/baidu_photo/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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
}
19 changes: 9 additions & 10 deletions drivers/thunder/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
}

Expand Down

0 comments on commit a90ef20

Please sign in to comment.