From 8c3603bcad7970dcfc16bc09f02581eb27b5684e Mon Sep 17 00:00:00 2001 From: Cp0204 Date: Tue, 2 Apr 2024 02:17:29 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=B6=8550=E4=BB=BB=E5=8A=A1?= =?UTF-8?q?fid=E8=B6=85=E9=99=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- quark_auto_save.py | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/quark_auto_save.py b/quark_auto_save.py index 81f57e6..9182ba5 100644 --- a/quark_auto_save.py +++ b/quark_auto_save.py @@ -182,14 +182,24 @@ def get_detail(pwd_id, stoken, pdir_fid): def get_fids(file_paths): - url = "https://drive.quark.cn/1/clouddrive/file/info/path_list" - querystring = {"pr": "ucpro", "fr": "pc"} - payload = {"file_path": file_paths, "namespace": "0"} - headers = common_headers() - response = requests.request( - "POST", url, json=payload, headers=headers, params=querystring - ).json() - return response + fids = [] + while True: + url = "https://drive.quark.cn/1/clouddrive/file/info/path_list" + querystring = {"pr": "ucpro", "fr": "pc"} + payload = {"file_path": file_paths[:50], "namespace": "0"} + headers = common_headers() + response = requests.request( + "POST", url, json=payload, headers=headers, params=querystring + ).json() + if(response["code"] == 0): + fids += response["data"] + file_paths = file_paths[50:] + else: + print(f"获取目录ID:失败, {response["message"]}") + break + if(len(file_paths) == 0): + break + return fids def ls_dir(pdir_fid): @@ -286,11 +296,7 @@ def update_savepath_fid(tasklist): ] if not dir_paths: return False - get_fids_return = get_fids(dir_paths) - if(get_fids_return["code"] != 0): - print(f"获取目录ID:失败, {get_fids_return["message"]}") - return False - dir_paths_exist_arr = get_fids_return["data"] + dir_paths_exist_arr = get_fids(dir_paths) dir_paths_exist = [item["file_path"] for item in dir_paths_exist_arr] # 比较创建不存在的 dir_paths_unexist = list(set(dir_paths) - set(dir_paths_exist))