🎇 get 189 redirect url
This commit is contained in:
parent
da74e29b26
commit
4466cb19a5
@ -215,6 +215,10 @@ func (c Cloud189) Link(path string, account *model.Account) (string, error) {
|
|||||||
if resp.ResCode != 0 {
|
if resp.ResCode != 0 {
|
||||||
return "", fmt.Errorf(resp.ResMessage)
|
return "", fmt.Errorf(resp.ResMessage)
|
||||||
}
|
}
|
||||||
|
res, err := noRedirectClient.R().Get(resp.FileDownloadUrl)
|
||||||
|
if res.StatusCode() == 302 {
|
||||||
|
return res.Header().Get("location"), nil
|
||||||
|
}
|
||||||
return resp.FileDownloadUrl, nil
|
return resp.FileDownloadUrl, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -233,13 +237,13 @@ func init() {
|
|||||||
client189Map = make(map[string]*resty.Client, 0)
|
client189Map = make(map[string]*resty.Client, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
// refer to PanIndex
|
|
||||||
type LoginResp struct {
|
type LoginResp struct {
|
||||||
Msg string `json:"msg"`
|
Msg string `json:"msg"`
|
||||||
Result int `json:"result"`
|
Result int `json:"result"`
|
||||||
ToUrl string `json:"toUrl"`
|
ToUrl string `json:"toUrl"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Login refer to PanIndex
|
||||||
func (c Cloud189) Login(account *model.Account) error {
|
func (c Cloud189) Login(account *model.Account) error {
|
||||||
client, ok := client189Map[account.Name]
|
client, ok := client189Map[account.Name]
|
||||||
if !ok {
|
if !ok {
|
||||||
|
@ -3,6 +3,8 @@ package drivers
|
|||||||
import (
|
import (
|
||||||
"github.com/Xhofe/alist/model"
|
"github.com/Xhofe/alist/model"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
|
"github.com/go-resty/resty/v2"
|
||||||
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Driver interface {
|
type Driver interface {
|
||||||
@ -53,3 +55,13 @@ func GetDrivers() map[string][]Item {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type Json map[string]interface{}
|
type Json map[string]interface{}
|
||||||
|
|
||||||
|
var noRedirectClient *resty.Client
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
noRedirectClient = resty.New().SetRedirectPolicy(
|
||||||
|
resty.RedirectPolicyFunc(func(req *http.Request, via []*http.Request) error {
|
||||||
|
return http.ErrUseLastResponse
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user