Quan666 / PikPakAPI

PikPak API
136 stars 42 forks source link

[enhancement] 没有decompress接口 Q-Q #15

Open ZHLONG-CN opened 1 year ago

ZHLONG-CN commented 1 year ago

查看压缩文件列表和解压压缩文件 API 接口

查看压缩文件列表

#  请求
POST https://api-drive.mypikpak.com/decompress/v1/list

{"gcid":"<file_hash>","path":"<path, 可空>","file_id":"<file_id>,"password":"<password, 可空>"}

# 以上 file_hash 由 GET https://api-drive.mypikpak.com/drive/v1/files/<file_id> 后 response.json()['hash'] 获得.

# 响应
{"status":"OK","status_text":"","task_id":"","current_path":"<path>","title":"<file_name>","file_size":"<file_size_bytes>","gcid":"<file_hash>","files":[
    {'filename': ...
     'filesize': ...
     'gcid': ...  # 为空
     'icon_lik': ...
     'index': ...
     'kind': ...
     'mine_type': ...
     'path': ...  # 相对于压缩包文件的绝对路径
    }, ...
]}

解压所有文件

# 请求
POST https://api-drive.mypikpak.com/decompress/v1/decompress

{"gcid":"<file_hash>","password":"<password, 可空>","file_id":"<file_id>","files":[],"default_parent":true}

# 响应
{"status":"OK","status_text":"","task_id":"<task_id>","files_num":<files_num>,"redirect_link":""}

通过 task_id 使用 progress API 可以获得解压进度

# 请求
GET https://api-drive.mypikpak.com/decompress/v1/progress?task_id=<task_id>

# 响应1
{"progress":7,"expires_in":1,"phase":"PHASE_TYPE_RUNNING", "file_id":""...}

# 响应2
{"progress":100,"expires_in":999,"phase":"PHASE_TYPE_COMPLETE","file_id":"<解压完成的文件夹id>", ...}

另外想请教 client_id 如何获取才能不需要附上x-device-idx-captcha-token的header. 我自己电脑上登录时有生成client_id和其余两个字段, 但是登录后使用其jwt需要附上两两匹配的x-device-idx-captcha-token, 否则响应400/401错误.

没有 x-device-id header
{"error":"invalid_argument","error_code":3,"error_url":"","error_description":"Request parameter error","error_details":[{"@type":"type.googleapis.com/google.rpc.DebugInfo","stack_entries":[],"detail":"device_id is empty"}]}

没有 x-captcha-token header
{"error":"captcha_invalid","error_code":9,"error_url":"","error_description":"Verification code is invalid","error_details":[{"@type":"type.googleapis.com/google.rpc.DebugInfo","stack_entries":[],"detail":"captcha_token is empty"}]}

x-captcha-token header 乱填
{"error":"captcha_invalid","error_code":9,"error_url":"","error_description":"验证码无效","error_details":[{"@type":"type.googleapis.com/google.rpc.DebugInfo","stack_entries":[],"detail":"no client info found"}]}

仅更换 x-device-id 但不更换 x-captcha-token
{"error":"captcha_invalid","error_code":9,"error_url":"","error_description":"验证码无效","error_details":[{"@type":"type.googleapis.com/google.rpc.DebugInfo","stack_entries":[],"detail":"device not match"}]}

x-device-id 生成算法似乎使用了随机数. 如下.

_.prototype._uuidv4 = function() {
                return "xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx".replace(/[xy]/g, function(r) {
                    var e = Math.random() * 16 | 0
                      , t = r == "x" ? e : e & 3 | 8;
                    return t.toString(16)
                })
            }
Quan666 commented 5 months ago

不用 x-device-id 和 x-captcha-token 不能调用这个接口吗?

ZHLONG-CN commented 4 months ago

不用 x-device-id 和 x-captcha-token 不能调用这个接口吗?

这两个字段不影响调用这个接口.

x-device-id 和 x-captcha-token 是用于获取 client_id 进行登录的.

我看到很多个项目的 client_id 都是用一个静态值 CLIENT_ID = "YNxT9w7GMdWvEOKa" . 我尝试过根据我自己抓包的结果, 发现他获取了一个新的 client_id, 请求头用了 x-device-id和x-captcha-token字段.

Quan666 commented 4 months ago

不用 x-device-id 和 x-captcha-token 不能调用这个接口吗?

这两个字段不影响调用这个接口.

x-device-id 和 x-captcha-token 是用于获取 client_id 进行登录的.

我看到很多个项目的 client_id 都是用一个静态值 CLIENT_ID = "YNxT9w7GMdWvEOKa" . 我尝试过根据我自己抓包的结果, 发现他获取了一个新的 client_id, 请求头用了 x-device-id和x-captcha-token字段.

那就简单咯