diff --git a/drivers/xunlei/driver.go b/drivers/xunlei/driver.go index 160d09551f3..86c2d271378 100644 --- a/drivers/xunlei/driver.go +++ b/drivers/xunlei/driver.go @@ -62,13 +62,13 @@ func (x *XunLei) Init(ctx context.Context, storage model.Storage) (err error) { "j", "4scKJNdd7F27Hv7tbt", }, - DeviceID: "9aa5c268e7bcfc197a9ad88e2fb330e5", - ClientID: "Xp6vsxz_7IYVw2BB", - ClientSecret: "Xp6vsy4tN9toTVdMSpomVdXpRmES", - ClientVersion: "7.51.0.8196", - PackageName: "com.xunlei.downloadprovider", - UserAgent: "ANDROID-com.xunlei.downloadprovider/7.51.0.8196 netWorkType/5G appid/40 deviceName/Xiaomi_M2004j7ac deviceModel/M2004J7AC OSVersion/12 protocolVersion/301 platformVersion/10 sdkVersion/220200 Oauth2Client/0.9 (Linux 4_14_186-perf-gddfs8vbb238b) (JAVA 0)", - DownUserAgent: "Dalvik/2.1.0 (Linux; U; Android 12; M2004J7AC Build/SP1A.210812.016)", + DeviceID: "9aa5c268e7bcfc197a9ad88e2fb330e5", + ClientID: "Xp6vsxz_7IYVw2BB", + ClientSecret: "Xp6vsy4tN9toTVdMSpomVdXpRmES", + ClientVersion: "7.51.0.8196", + PackageName: "com.xunlei.downloadprovider", + UserAgent: "ANDROID-com.xunlei.downloadprovider/7.51.0.8196 netWorkType/5G appid/40 deviceName/Xiaomi_M2004j7ac deviceModel/M2004J7AC OSVersion/12 protocolVersion/301 platformVersion/10 sdkVersion/220200 Oauth2Client/0.9 (Linux 4_14_186-perf-gddfs8vbb238b) (JAVA 0)", + DownloadUserAgent: "Dalvik/2.1.0 (Linux; U; Android 12; M2004J7AC Build/SP1A.210812.016)", }, refreshTokenFunc: func() error { // 通过RefreshToken刷新 @@ -142,13 +142,13 @@ func (x *XunLeiExpert) Init(ctx context.Context, storage model.Storage) (err err Common: &Common{ client: base.NewRestyClient(), - DeviceID: x.DeviceID, - ClientID: x.ClientID, - ClientSecret: x.ClientSecret, - ClientVersion: x.ClientVersion, - PackageName: x.PackageName, - UserAgent: x.UserAgent, - DownUserAgent: x.DownUserAgent, + DeviceID: x.DeviceID, + ClientID: x.ClientID, + ClientSecret: x.ClientSecret, + ClientVersion: x.ClientVersion, + PackageName: x.PackageName, + UserAgent: x.UserAgent, + DownloadUserAgent: x.DownloadUserAgent, }, } @@ -158,7 +158,7 @@ func (x *XunLeiExpert) Init(ctx context.Context, storage model.Storage) (err err } // 签名方法 - if x.SignType == "capcha_sign" { + if x.SignType == "captcha_sign" { x.Common.Timestamp = x.Timestamp x.Common.CaptchaSign = x.CaptchaSign } else { @@ -210,6 +210,8 @@ func (x *XunLeiExpert) Init(ctx context.Context, storage model.Storage) (err err x.SetCaptchaToken(x.CaptchaToken) x.CaptchaToken = "" } + x.XunLeiCommon.UserAgent = x.UserAgent + x.XunLeiCommon.DownloadUserAgent = x.DownloadUserAgent } return nil } @@ -249,7 +251,7 @@ func (xc *XunLeiCommon) Link(ctx context.Context, file model.Obj, args model.Lin link := &model.Link{ URL: lFile.WebContentLink, Header: http.Header{ - "User-Agent": {xc.DownUserAgent}, + "User-Agent": {xc.DownloadUserAgent}, }, } diff --git a/drivers/xunlei/meta.go b/drivers/xunlei/meta.go index 3165dd52df4..7eb12b62a5b 100644 --- a/drivers/xunlei/meta.go +++ b/drivers/xunlei/meta.go @@ -14,7 +14,7 @@ type ExpertAddition struct { driver.RootID LoginType string `json:"login_type" type:"select" options:"user,refresh_token" default:"user"` - SignType string `json:"sign_type" type:"select" options:"algorithms,capcha_sign" default:"algorithms"` + SignType string `json:"sign_type" type:"select" options:"algorithms,captcha_sign" default:"algorithms"` // 登录方式1 Username string `json:"username" required:"true" help:"login type is user,this is required"` @@ -25,8 +25,8 @@ type ExpertAddition struct { // 签名方法1 Algorithms string `json:"algorithms" required:"true" help:"sign type is algorithms,this is required" default:"HPxr4BVygTQVtQkIMwQH33ywbgYG5l4JoR,GzhNkZ8pOBsCY+7,v+l0ImTpG7c7/,e5ztohgVXNP,t,EbXUWyVVqQbQX39Mbjn2geok3/0WEkAVxeqhtx857++kjJiRheP8l77gO,o7dvYgbRMOpHXxCs,6MW8TD8DphmakaxCqVrfv7NReRRN7ck3KLnXBculD58MvxjFRqT+,kmo0HxCKVfmxoZswLB4bVA/dwqbVAYghSb,j,4scKJNdd7F27Hv7tbt"` // 签名方法2 - CaptchaSign string `json:"captcha_sign" required:"true" help:"sign type is capcha_sign,this is required"` - Timestamp string `json:"timestamp" required:"true" help:"sign type is capcha_sign,this is required"` + CaptchaSign string `json:"captcha_sign" required:"true" help:"sign type is captcha_sign,this is required"` + Timestamp string `json:"timestamp" required:"true" help:"sign type is captcha_sign,this is required"` // 验证码 CaptchaToken string `json:"captcha_token"` @@ -39,8 +39,8 @@ type ExpertAddition struct { PackageName string `json:"package_name" required:"true" default:"com.xunlei.downloadprovider"` //不影响登录,影响下载速度 - UserAgent string `json:"user_agent" required:"true" default:"ANDROID-com.xunlei.downloadprovider/7.51.0.8196 netWorkType/4G appid/40 deviceName/Xiaomi_M2004j7ac deviceModel/M2004J7AC OSVersion/12 protocolVersion/301 platformVersion/10 sdkVersion/220200 Oauth2Client/0.9 (Linux 4_14_186-perf-gdcf98eab238b) (JAVA 0)"` - DownUserAgent string `json:"down_user_agent" required:"true" default:"Dalvik/2.1.0 (Linux; U; Android 12; M2004J7AC Build/SP1A.210812.016)"` + UserAgent string `json:"user_agent" required:"true" default:"ANDROID-com.xunlei.downloadprovider/7.51.0.8196 netWorkType/4G appid/40 deviceName/Xiaomi_M2004j7ac deviceModel/M2004J7AC OSVersion/12 protocolVersion/301 platformVersion/10 sdkVersion/220200 Oauth2Client/0.9 (Linux 4_14_186-perf-gdcf98eab238b) (JAVA 0)"` + DownloadUserAgent string `json:"download_user_agent" required:"true" default:"Dalvik/2.1.0 (Linux; U; Android 12; M2004J7AC Build/SP1A.210812.016)"` } // 登录特征,用于判断是否重新登录 @@ -52,7 +52,7 @@ func (i *ExpertAddition) GetIdentity() string { hash.Write([]byte(i.Username + i.Password)) } - if i.SignType == "capcha_sign" { + if i.SignType == "captcha_sign" { hash.Write([]byte(i.CaptchaSign + i.Timestamp)) } else { hash.Write([]byte(i.Algorithms)) diff --git a/drivers/xunlei/util.go b/drivers/xunlei/util.go index 427f3812704..998253da6c5 100644 --- a/drivers/xunlei/util.go +++ b/drivers/xunlei/util.go @@ -45,13 +45,13 @@ type Common struct { Timestamp, CaptchaSign string // 必要值,签名相关 - DeviceID string - ClientID string - ClientSecret string - ClientVersion string - PackageName string - UserAgent string - DownUserAgent string + DeviceID string + ClientID string + ClientSecret string + ClientVersion string + PackageName string + UserAgent string + DownloadUserAgent string } func (c *Common) SetCaptchaToken(captchaToken string) {