style: 统一 Ruff 代码格式
This commit is contained in:
+20
-18
@@ -47,7 +47,9 @@ class LoginAPIStrategy(ABC):
|
||||
...
|
||||
|
||||
@abstractmethod
|
||||
def build_first_login_data(self, username: str, password: str, referer: str) -> dict:
|
||||
def build_first_login_data(
|
||||
self, username: str, password: str, referer: str
|
||||
) -> dict:
|
||||
"""构建第一次登录请求参数(获取极验参数)"""
|
||||
...
|
||||
|
||||
@@ -85,11 +87,11 @@ class LoginAPIStrategy(ABC):
|
||||
Returns:
|
||||
(gt, challenge, code_token)
|
||||
"""
|
||||
geetest_data = payload.get('data', {}).get('geetest', {})
|
||||
code_data = geetest_data.get('code_data', {})
|
||||
gt = code_data.get('gt', '')
|
||||
challenge = code_data.get('challenge', '')
|
||||
code_token = geetest_data.get('code_token', '')
|
||||
geetest_data = payload.get("data", {}).get("geetest", {})
|
||||
code_data = geetest_data.get("code_data", {})
|
||||
gt = code_data.get("gt", "")
|
||||
challenge = code_data.get("challenge", "")
|
||||
code_token = geetest_data.get("code_token", "")
|
||||
return gt, challenge, code_token
|
||||
|
||||
def extract_remote_code(self, payload: dict) -> str:
|
||||
@@ -101,7 +103,7 @@ class LoginAPIStrategy(ABC):
|
||||
Returns:
|
||||
remote_code 字符串
|
||||
"""
|
||||
return payload.get('data', {}).get('remoteLogin', {}).get('code', '')
|
||||
return payload.get("data", {}).get("remoteLogin", {}).get("code", "")
|
||||
|
||||
def extract_login_url(self, payload: dict) -> str:
|
||||
"""从验证码响应提取登录 URL
|
||||
@@ -112,27 +114,27 @@ class LoginAPIStrategy(ABC):
|
||||
Returns:
|
||||
登录回调 URL
|
||||
"""
|
||||
data = payload.get('data', {})
|
||||
data = payload.get("data", {})
|
||||
if not isinstance(data, dict):
|
||||
return ''
|
||||
return ""
|
||||
|
||||
# `remoteLogin` 与“跳过绑定手机号”完成后都会返回同类回调地址,
|
||||
# 但不同版本接口的字段命名不完全一致。
|
||||
for key in ('url', 'loginUrl', 'login_url', 'redirectUrl', 'redirect_url'):
|
||||
for key in ("url", "loginUrl", "login_url", "redirectUrl", "redirect_url"):
|
||||
value = data.get(key)
|
||||
if isinstance(value, str) and value:
|
||||
return value
|
||||
return ''
|
||||
return ""
|
||||
|
||||
def extract_mobile_bind_unique_key(self, payload: dict) -> str:
|
||||
"""提取服务端要求绑定手机号时返回的一次性继续登录标识。"""
|
||||
data = payload.get('data', {})
|
||||
data = payload.get("data", {})
|
||||
if not isinstance(data, dict):
|
||||
return ''
|
||||
return ""
|
||||
|
||||
def find_unique_key(value: object) -> str:
|
||||
if isinstance(value, dict):
|
||||
unique_key = value.get('uniqueKey') or value.get('unique_key')
|
||||
unique_key = value.get("uniqueKey") or value.get("unique_key")
|
||||
if isinstance(unique_key, str) and unique_key:
|
||||
return unique_key
|
||||
for child in value.values():
|
||||
@@ -144,14 +146,14 @@ class LoginAPIStrategy(ABC):
|
||||
result = find_unique_key(child)
|
||||
if result:
|
||||
return result
|
||||
return ''
|
||||
return ""
|
||||
|
||||
return find_unique_key(data)
|
||||
|
||||
def build_skip_mobile_bind_data(self, unique_key: str) -> dict:
|
||||
"""构建跳过手机号绑定、继续完成网页登录的请求参数。"""
|
||||
return {
|
||||
'type': '3',
|
||||
'uniqueKey': unique_key,
|
||||
'biz_type': '1',
|
||||
"type": "3",
|
||||
"uniqueKey": unique_key,
|
||||
"biz_type": "1",
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user