@@ -36,7 +36,6 @@ func (d *PikPak) GetAddition() driver.Additional {
36
36
}
37
37
38
38
func (d * PikPak ) Init (ctx context.Context ) (err error ) {
39
-
40
39
if d .Common == nil {
41
40
d .Common = & Common {
42
41
client : base .NewRestyClient (),
@@ -247,7 +246,7 @@ func (d *PikPak) Put(ctx context.Context, dstDir model.Obj, stream model.FileStr
247
246
}
248
247
249
248
params := resp .Resumable .Params
250
- //endpoint := strings.Join(strings.Split(params.Endpoint, ".")[1:], ".")
249
+ // endpoint := strings.Join(strings.Split(params.Endpoint, ".")[1:], ".")
251
250
// web 端上传 返回的endpoint 为 `mypikpak.net` | android 端上传 返回的endpoint 为 `vip-lixian-07.mypikpak.net`·
252
251
if d .Addition .Platform == "android" {
253
252
params .Endpoint = "mypikpak.net"
@@ -260,6 +259,27 @@ func (d *PikPak) Put(ctx context.Context, dstDir model.Obj, stream model.FileStr
260
259
return d .UploadByMultipart (ctx , & params , stream .GetSize (), stream , up )
261
260
}
262
261
262
+ func (d * PikPak ) GetDetails (ctx context.Context ) (* model.StorageDetails , error ) {
263
+ var about AboutResponse
264
+ _ , err := d .request ("https://api-drive.mypikpak.com/drive/v1/about" , http .MethodGet , func (req * resty.Request ) {
265
+ req .SetContext (ctx )
266
+ }, & about )
267
+ if err != nil {
268
+ return nil , err
269
+ }
270
+ total , err := strconv .ParseUint (about .Quota .Limit , 10 , 64 )
271
+ if err != nil {
272
+ return nil , err
273
+ }
274
+ used , err := strconv .ParseUint (about .Quota .Usage , 10 , 64 )
275
+ if err != nil {
276
+ return nil , err
277
+ }
278
+ return & model.StorageDetails {
279
+ DiskUsage : driver .DiskUsageFromUsedAndTotal (used , total ),
280
+ }, nil
281
+ }
282
+
263
283
// 离线下载文件
264
284
func (d * PikPak ) OfflineDownload (ctx context.Context , fileUrl string , parentDir model.Obj , fileName string ) (* OfflineTask , error ) {
265
285
requestBody := base.Json {
@@ -278,7 +298,6 @@ func (d *PikPak) OfflineDownload(ctx context.Context, fileUrl string, parentDir
278
298
req .SetContext (ctx ).
279
299
SetBody (requestBody )
280
300
}, & resp )
281
-
282
301
if err != nil {
283
302
return nil , err
284
303
}
@@ -325,7 +344,6 @@ func (d *PikPak) OfflineList(ctx context.Context, nextPageToken string, phase []
325
344
req .SetContext (ctx ).
326
345
SetQueryParams (params )
327
346
}, & resp )
328
-
329
347
if err != nil {
330
348
return nil , fmt .Errorf ("failed to get offline list: %w" , err )
331
349
}
0 commit comments