Skip to content

Commit

Permalink
chore: fix xunlei some minor problems
Browse files Browse the repository at this point in the history
  • Loading branch information
foxxorcat committed Sep 11, 2022
1 parent b00dcde commit 537ca03
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 29 deletions.
34 changes: 18 additions & 16 deletions drivers/xunlei/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -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刷新
Expand Down Expand Up @@ -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,
},
}

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

Expand Down
12 changes: 6 additions & 6 deletions drivers/xunlei/meta.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand All @@ -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"`
Expand All @@ -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)"`
}

// 登录特征,用于判断是否重新登录
Expand All @@ -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))
Expand Down
14 changes: 7 additions & 7 deletions drivers/xunlei/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 537ca03

Please sign in to comment.