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
@@ -322,6 +325,7 @@ func (xc *XunLeiCommon) MakeDir(ctx context.Context, parentDir model.Obj, dirNam
322325 "kind" : FOLDER ,
323326 "name" : dirName ,
324327 "parent_id" : parentDir .GetID (),
328+ "space" : xc .Space ,
325329 })
326330 }, nil )
327331 return err
@@ -331,8 +335,9 @@ func (xc *XunLeiCommon) Move(ctx context.Context, srcObj, dstDir model.Obj) erro
331335 _ , err := xc .Request (FILE_API_URL + ":batchMove" , http .MethodPost , func (r * resty.Request ) {
332336 r .SetContext (ctx )
333337 r .SetBody (& base.Json {
334- "to" : base.Json {"parent_id" : dstDir .GetID ()},
335- "ids" : []string {srcObj .GetID ()},
338+ "to" : base.Json {"parent_id" : dstDir .GetID ()},
339+ "ids" : []string {srcObj .GetID ()},
340+ "space" : xc .Space ,
336341 })
337342 }, nil )
338343 return err
@@ -342,7 +347,10 @@ func (xc *XunLeiCommon) Rename(ctx context.Context, srcObj model.Obj, newName st
342347 _ , err := xc .Request (FILE_API_URL + "/{fileID}" , http .MethodPatch , func (r * resty.Request ) {
343348 r .SetContext (ctx )
344349 r .SetPathParam ("fileID" , srcObj .GetID ())
345- r .SetBody (& base.Json {"name" : newName })
350+ r .SetBody (& base.Json {
351+ "name" : newName ,
352+ "space" : xc .Space ,
353+ })
346354 }, nil )
347355 return err
348356}
@@ -351,8 +359,9 @@ func (xc *XunLeiCommon) Copy(ctx context.Context, srcObj, dstDir model.Obj) erro
351359 _ , err := xc .Request (FILE_API_URL + ":batchCopy" , http .MethodPost , func (r * resty.Request ) {
352360 r .SetContext (ctx )
353361 r .SetBody (& base.Json {
354- "to" : base.Json {"parent_id" : dstDir .GetID ()},
355- "ids" : []string {srcObj .GetID ()},
362+ "to" : base.Json {"parent_id" : dstDir .GetID ()},
363+ "ids" : []string {srcObj .GetID ()},
364+ "space" : xc .Space ,
356365 })
357366 }, nil )
358367 return err
@@ -362,6 +371,7 @@ func (xc *XunLeiCommon) Remove(ctx context.Context, obj model.Obj) error {
362371 _ , err := xc .Request (FILE_API_URL + "/{fileID}/trash" , http .MethodPatch , func (r * resty.Request ) {
363372 r .SetContext (ctx )
364373 r .SetPathParam ("fileID" , obj .GetID ())
374+ r .SetQueryParam ("space" , xc .Space )
365375 r .SetBody ("{}" )
366376 }, nil )
367377 return err
@@ -387,6 +397,7 @@ func (xc *XunLeiCommon) Put(ctx context.Context, dstDir model.Obj, file model.Fi
387397 "size" : file .GetSize (),
388398 "hash" : gcid ,
389399 "upload_type" : UPLOAD_TYPE_RESUMABLE ,
400+ "space" : xc .Space ,
390401 })
391402 }, & resp )
392403 if err != nil {
@@ -430,7 +441,7 @@ func (xc *XunLeiCommon) getFiles(ctx context.Context, folderId string) ([]model.
430441 _ , err := xc .Request (FILE_API_URL , http .MethodGet , func (r * resty.Request ) {
431442 r .SetContext (ctx )
432443 r .SetQueryParams (map [string ]string {
433- "space" : "" ,
444+ "space" : xc . Space ,
434445 "__type" : "drive" ,
435446 "refresh" : "true" ,
436447 "__sync" : "true" ,
@@ -440,6 +451,17 @@ func (xc *XunLeiCommon) getFiles(ctx context.Context, folderId string) ([]model.
440451 "limit" : "100" ,
441452 "filters" : `{"phase":{"eq":"PHASE_TYPE_COMPLETE"},"trashed":{"eq":false}}` ,
442453 })
454+ // 获取硬盘挂载目录等
455+ if xc .Space != "" {
456+ r .SetQueryParamsFromValues (url.Values {
457+ "with" : []string {
458+ "withCategoryDiskMountPath" ,
459+ "withCategoryDriveCachePath" ,
460+ "withCategoryHistoryDownloadPath" ,
461+ "withReadOnlyFS" ,
462+ },
463+ })
464+ }
443465 }, & fileList )
444466 if err != nil {
445467 return nil , err
@@ -576,6 +598,7 @@ func (xc *XunLeiCommon) OfflineDownload(ctx context.Context, fileUrl string, par
576598 "name" : fileName ,
577599 "parent_id" : parentDir .GetID (),
578600 "upload_type" : UPLOAD_TYPE_URL ,
601+ "space" : xc .Space ,
579602 "url" : base.Json {
580603 "url" : fileUrl ,
581604 },
@@ -602,6 +625,7 @@ func (xc *XunLeiCommon) OfflineList(ctx context.Context, nextPageToken string) (
602625 "type" : "offline" ,
603626 "limit" : "10000" ,
604627 "page_token" : nextPageToken ,
628+ "space" : xc .Space ,
605629 })
606630 }, & resp )
607631
@@ -618,6 +642,7 @@ func (xc *XunLeiCommon) DeleteOfflineTasks(ctx context.Context, taskIDs []string
618642 SetQueryParams (map [string ]string {
619643 "task_ids" : strings .Join (taskIDs , "," ),
620644 "delete_files" : strconv .FormatBool (deleteFiles ),
645+ "space" : xc .Space ,
621646 })
622647 }, nil )
623648 if err != nil {
0 commit comments