@@ -36,7 +36,6 @@ func (d *PikPak) GetAddition() driver.Additional {
3636}
3737
3838func (d * PikPak ) Init (ctx context.Context ) (err error ) {
39-
4039 if d .Common == nil {
4140 d .Common = & Common {
4241 client : base .NewRestyClient (),
@@ -247,7 +246,7 @@ func (d *PikPak) Put(ctx context.Context, dstDir model.Obj, stream model.FileStr
247246 }
248247
249248 params := resp .Resumable .Params
250- //endpoint := strings.Join(strings.Split(params.Endpoint, ".")[1:], ".")
249+ // endpoint := strings.Join(strings.Split(params.Endpoint, ".")[1:], ".")
251250 // web 端上传 返回的endpoint 为 `mypikpak.net` | android 端上传 返回的endpoint 为 `vip-lixian-07.mypikpak.net`·
252251 if d .Addition .Platform == "android" {
253252 params .Endpoint = "mypikpak.net"
@@ -260,6 +259,27 @@ func (d *PikPak) Put(ctx context.Context, dstDir model.Obj, stream model.FileStr
260259 return d .UploadByMultipart (ctx , & params , stream .GetSize (), stream , up )
261260}
262261
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+
263283// 离线下载文件
264284func (d * PikPak ) OfflineDownload (ctx context.Context , fileUrl string , parentDir model.Obj , fileName string ) (* OfflineTask , error ) {
265285 requestBody := base.Json {
@@ -278,7 +298,6 @@ func (d *PikPak) OfflineDownload(ctx context.Context, fileUrl string, parentDir
278298 req .SetContext (ctx ).
279299 SetBody (requestBody )
280300 }, & resp )
281-
282301 if err != nil {
283302 return nil , err
284303 }
@@ -325,7 +344,6 @@ func (d *PikPak) OfflineList(ctx context.Context, nextPageToken string, phase []
325344 req .SetContext (ctx ).
326345 SetQueryParams (params )
327346 }, & resp )
328-
329347 if err != nil {
330348 return nil , fmt .Errorf ("failed to get offline list: %w" , err )
331349 }
0 commit comments