♻️ 使用基础URL常量,便于维护

This commit is contained in:
Cp0204 2024-12-04 11:03:00 +08:00
parent 95d1449651
commit fdc4cbb2e8

View File

@ -100,6 +100,9 @@ def get_cookies(cookie_val):
class Quark:
BASE_URL = "https://drive-pc.quark.cn"
BASE_URL_APP = "https://drive-m.quark.cn"
def __init__(self, cookie, index=None):
self.cookie = cookie.strip()
self.index = index + 1
@ -161,7 +164,7 @@ class Quark:
return False
def get_growth_info(self):
url = "https://drive-m.quark.cn/1/clouddrive/capacity/growth/info"
url = f"{self.BASE_URL_APP}/1/clouddrive/capacity/growth/info"
querystring = {
"pr": "ucpro",
"fr": "android",
@ -181,7 +184,7 @@ class Quark:
return False
def get_growth_sign(self):
url = "https://drive-m.quark.cn/1/clouddrive/capacity/growth/sign"
url = f"{self.BASE_URL_APP}/1/clouddrive/capacity/growth/sign"
querystring = {
"pr": "ucpro",
"fr": "android",
@ -205,7 +208,7 @@ class Quark:
# 可验证资源是否失效
def get_stoken(self, pwd_id, passcode=""):
url = "https://drive-h.quark.cn/1/clouddrive/share/sharepage/token"
url = f"{self.BASE_URL}/1/clouddrive/share/sharepage/token"
querystring = {"pr": "ucpro", "fr": "pc"}
payload = {"pwd_id": pwd_id, "passcode": passcode}
response = self._send_request(
@ -220,7 +223,7 @@ class Quark:
list_merge = []
page = 1
while True:
url = "https://drive-h.quark.cn/1/clouddrive/share/sharepage/detail"
url = f"{self.BASE_URL}/1/clouddrive/share/sharepage/detail"
querystring = {
"pr": "ucpro",
"fr": "pc",
@ -249,7 +252,7 @@ class Quark:
def get_fids(self, file_paths):
fids = []
while True:
url = "https://drive-h.quark.cn/1/clouddrive/file/info/path_list"
url = f"{self.BASE_URL}/1/clouddrive/file/info/path_list"
querystring = {"pr": "ucpro", "fr": "pc"}
payload = {"file_path": file_paths[:50], "namespace": "0"}
response = self._send_request(
@ -269,7 +272,7 @@ class Quark:
file_list = []
page = 1
while True:
url = "https://drive-h.quark.cn/1/clouddrive/file/sort"
url = f"{self.BASE_URL}/1/clouddrive/file/sort"
querystring = {
"pr": "ucpro",
"fr": "pc",
@ -293,7 +296,7 @@ class Quark:
return file_list
def save_file(self, fid_list, fid_token_list, to_pdir_fid, pwd_id, stoken):
url = "https://drive-h.quark.cn/1/clouddrive/share/sharepage/save"
url = f"{self.BASE_URL}/1/clouddrive/share/sharepage/save"
querystring = {
"pr": "ucpro",
"fr": "pc",
@ -319,7 +322,7 @@ class Quark:
def query_task(self, task_id):
retry_index = 0
while True:
url = "https://drive-h.quark.cn/1/clouddrive/task"
url = f"{self.BASE_URL}/1/clouddrive/task"
querystring = {
"pr": "ucpro",
"fr": "pc",
@ -348,7 +351,7 @@ class Quark:
return response
def download(self, fids):
url = "https://drive-h.quark.cn/1/clouddrive/file/download"
url = f"{self.BASE_URL}/1/clouddrive/file/download"
querystring = {"pr": "ucpro", "fr": "pc", "uc_param_str": ""}
payload = {"fids": fids}
response = self._send_request("POST", url, json=payload, params=querystring)
@ -357,7 +360,7 @@ class Quark:
return response.json(), cookie_str
def mkdir(self, dir_path):
url = "https://drive-h.quark.cn/1/clouddrive/file"
url = f"{self.BASE_URL}/1/clouddrive/file"
querystring = {"pr": "ucpro", "fr": "pc", "uc_param_str": ""}
payload = {
"pdir_fid": "0",
@ -371,7 +374,7 @@ class Quark:
return response
def rename(self, fid, file_name):
url = "https://drive-h.quark.cn/1/clouddrive/file/rename"
url = f"{self.BASE_URL}/1/clouddrive/file/rename"
querystring = {"pr": "ucpro", "fr": "pc", "uc_param_str": ""}
payload = {"fid": fid, "file_name": file_name}
response = self._send_request(
@ -380,7 +383,7 @@ class Quark:
return response
def delete(self, filelist):
url = "https://drive-h.quark.cn/1/clouddrive/file/delete"
url = f"{self.BASE_URL}/1/clouddrive/file/delete"
querystring = {"pr": "ucpro", "fr": "pc", "uc_param_str": ""}
payload = {"action_type": 2, "filelist": filelist, "exclude_fids": []}
response = self._send_request(
@ -389,7 +392,7 @@ class Quark:
return response
def recycle_list(self, page=1, size=30):
url = "https://drive-h.quark.cn/1/clouddrive/file/recycle/list"
url = f"{self.BASE_URL}/1/clouddrive/file/recycle/list"
querystring = {
"_page": page,
"_size": size,
@ -401,7 +404,7 @@ class Quark:
return response["data"]["list"]
def recycle_remove(self, record_list):
url = "https://drive-h.quark.cn/1/clouddrive/file/recycle/remove"
url = f"{self.BASE_URL}/1/clouddrive/file/recycle/remove"
querystring = {"uc_param_str": "", "fr": "pc", "pr": "ucpro"}
payload = {
"select_mode": 2,