Skip to content

Commit 2c54c56

Browse files
committed
feat(thunder): allow setting space
1 parent e97f0a2 commit 2c54c56

File tree

3 files changed

+20
-3
lines changed

3 files changed

+20
-3
lines changed

drivers/thunder/driver.go

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"context"
55
"fmt"
66
"net/http"
7+
"net/url"
78
"strconv"
89
"strings"
910

@@ -68,6 +69,7 @@ func (x *Thunder) Init(ctx context.Context) (err error) {
6869
PackageName: "com.xunlei.downloadprovider",
6970
UserAgent: "ANDROID-com.xunlei.downloadprovider/8.31.0.9726 netWorkType/5G appid/40 deviceName/Xiaomi_M2004j7ac deviceModel/M2004J7AC OSVersion/12 protocolVersion/301 platformVersion/10 sdkVersion/512000 Oauth2Client/0.9 (Linux 4_14_186-perf-gddfs8vbb238b) (JAVA 0)",
7071
DownloadUserAgent: "Dalvik/2.1.0 (Linux; U; Android 12; M2004J7AC Build/SP1A.210812.016)",
72+
Space: x.Space,
7173
refreshCTokenCk: func(token string) {
7274
x.CaptchaToken = token
7375
op.MustSaveDriverStorage(x)
@@ -167,6 +169,7 @@ func (x *ThunderExpert) Init(ctx context.Context) (err error) {
167169
UserAgent: x.UserAgent,
168170
DownloadUserAgent: x.DownloadUserAgent,
169171
UseVideoUrl: x.UseVideoUrl,
172+
Space: x.Space,
170173

171174
refreshCTokenCk: func(token string) {
172175
x.CaptchaToken = token
@@ -281,7 +284,7 @@ func (xc *XunLeiCommon) Link(ctx context.Context, file model.Obj, args model.Lin
281284
_, err := xc.Request(FILE_API_URL+"/{fileID}", http.MethodGet, func(r *resty.Request) {
282285
r.SetContext(ctx)
283286
r.SetPathParam("fileID", file.GetID())
284-
//r.SetQueryParam("space", "")
287+
r.SetQueryParam("space", xc.Space)
285288
}, &lFile)
286289
if err != nil {
287290
return nil, err
@@ -430,7 +433,7 @@ func (xc *XunLeiCommon) getFiles(ctx context.Context, folderId string) ([]model.
430433
_, err := xc.Request(FILE_API_URL, http.MethodGet, func(r *resty.Request) {
431434
r.SetContext(ctx)
432435
r.SetQueryParams(map[string]string{
433-
"space": "",
436+
"space": xc.Space,
434437
"__type": "drive",
435438
"refresh": "true",
436439
"__sync": "true",
@@ -440,6 +443,16 @@ func (xc *XunLeiCommon) getFiles(ctx context.Context, folderId string) ([]model.
440443
"limit": "100",
441444
"filters": `{"phase":{"eq":"PHASE_TYPE_COMPLETE"},"trashed":{"eq":false}}`,
442445
})
446+
if xc.Space != "" {
447+
r.SetQueryParamsFromValues(url.Values{
448+
"with": []string{
449+
"withCategoryDiskMountPath",
450+
"withCategoryDriveCachePath",
451+
"withCategoryHistoryDownloadPath",
452+
"withReadOnlyFS",
453+
},
454+
})
455+
}
443456
}, &fileList)
444457
if err != nil {
445458
return nil, err

drivers/thunder/meta.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ type ExpertAddition struct {
4646

4747
//优先使用视频链接代替下载链接
4848
UseVideoUrl bool `json:"use_video_url"`
49+
50+
Space string `json:"space" default:"" help:"device id for remote device"`
4951
}
5052

5153
// 登录特征,用于判断是否重新登录
@@ -80,6 +82,8 @@ type Addition struct {
8082
CreditKey string `json:"credit_key" help:"credit key,used for login"`
8183
// 登录设备ID
8284
DeviceID string `json:"device_id" default:""`
85+
86+
Space string `json:"space" default:"" help:"device id for remote device"`
8387
}
8488

8589
// 登录特征,用于判断是否重新登录
@@ -90,7 +94,6 @@ func (i *Addition) GetIdentity() string {
9094
var config = driver.Config{
9195
Name: "Thunder",
9296
LocalSort: true,
93-
OnlyProxy: true,
9497
}
9598

9699
var configExpert = driver.Config{

drivers/thunder/util.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ type Common struct {
6868
UserAgent string
6969
DownloadUserAgent string
7070
UseVideoUrl bool
71+
Space string
7172

7273
// 验证码token刷新成功回调
7374
refreshCTokenCk func(token string)

0 commit comments

Comments
 (0)