mirror of
https://github.com/0-8-4/miui-auto-tasks.git
synced 2025-02-07 02:49:09 +00:00
feat: geetest添加自定义返回参数 (#313)
* feat: 更改geetest验证方式 * feat: geetest添加自定义返回参数 * feat: geetest添加自定义返回参数 * Update pyproject.toml * Update Dockerfile
This commit is contained in:
parent
cbef91d4f5
commit
40d3c279e8
@ -8,7 +8,7 @@ WORKDIR /srv
|
||||
|
||||
COPY ./utils ./utils
|
||||
|
||||
COPY ./pyproject.toml ./pdm.lock ./miuitask.py ./docker_start.sh ./
|
||||
COPY ./pyproject.toml ./miuitask.py ./docker_start.sh ./
|
||||
|
||||
RUN pdm install --prod && \
|
||||
echo '0 4 * * * /bin/sh -c "sleep $((RANDOM % 1800 + 1)); cd /srv && pdm run /srv/miuitask.py"' > /var/spool/cron/crontabs/root && \
|
||||
|
@ -4,11 +4,9 @@ version = ""
|
||||
description = ""
|
||||
authors = []
|
||||
dependencies = [
|
||||
"orjson>=3.9.10",
|
||||
"loguru>=0.7.2",
|
||||
"pydantic>=2.4.2",
|
||||
"httpx>=0.25.1",
|
||||
"cryptography>=41.0.5",
|
||||
"cryptography=44.0.0",
|
||||
"pyyaml>=6.0.1",
|
||||
"tenacity>=8.2.3",
|
||||
"tzdata>=2023.3",
|
||||
|
@ -28,7 +28,7 @@ def find_key(data: dict, key: str):
|
||||
|
||||
|
||||
def get_validate_other(
|
||||
gt: str, challenge: str
|
||||
gt: str, challenge: str, result: str
|
||||
) -> GeetestResult: # pylint: disable=invalid-name
|
||||
"""获取人机验证结果"""
|
||||
try:
|
||||
@ -36,11 +36,11 @@ def get_validate_other(
|
||||
if _conf.preference.get_geetest_url:
|
||||
params = _conf.preference.get_geetest_params.copy()
|
||||
params = json.loads(
|
||||
json.dumps(params).replace("{gt}", gt).replace("{challenge}", challenge)
|
||||
json.dumps(params).replace("{gt}", gt).replace("{challenge}", challenge).replace("{result}", result)
|
||||
)
|
||||
data = _conf.preference.get_geetest_data.copy()
|
||||
data = json.loads(
|
||||
json.dumps(data).replace("{gt}", gt).replace("{challenge}", challenge)
|
||||
json.dumps(data).replace("{gt}", gt).replace("{challenge}", challenge).replace("{result}", result)
|
||||
)
|
||||
for i in range(10):
|
||||
log.info(f"第{i}次获取结果")
|
||||
@ -81,6 +81,7 @@ def get_validate(
|
||||
"""创建人机验证并结果"""
|
||||
try:
|
||||
validate = ""
|
||||
result = ""
|
||||
if _conf.preference.geetest_url:
|
||||
params = _conf.preference.geetest_params.copy()
|
||||
params = json.loads(
|
||||
@ -106,10 +107,14 @@ def get_validate(
|
||||
geetest_challenge_match = geetest_challenge_expr.find(result)
|
||||
if len(geetest_challenge_match) > 0:
|
||||
challenge = geetest_challenge_match[0].value
|
||||
geetest_result_expr = parse(_conf.preference.geetest_result_path)
|
||||
geetest_result_match = geetest_result_expr.find(result)
|
||||
if len(geetest_result_match) > 0:
|
||||
result = geetest_result_match[0].value
|
||||
if validate and challenge:
|
||||
return GeetestResult(challenge=challenge, validate=validate)
|
||||
else:
|
||||
return get_validate_other(gt=gt, challenge=challenge)
|
||||
return get_validate_other(gt=gt, challenge=challenge, result=result)
|
||||
else:
|
||||
return GeetestResult(challenge="", validate="")
|
||||
except Exception: # pylint: disable=broad-exception-caught
|
||||
|
@ -148,6 +148,7 @@ class Preference:
|
||||
geetest_data: Optional[dict] = None,
|
||||
geetest_validate_path="$.data.validate",
|
||||
geetest_challenge_path="$.data.challenge",
|
||||
geetest_result_path="",
|
||||
get_geetest_url="",
|
||||
get_geetest_method: Literal["post", "get"] = "post",
|
||||
get_geetest_params: Optional[dict] = None,
|
||||
@ -167,6 +168,8 @@ class Preference:
|
||||
"""极验验证validate的路径"""
|
||||
self.geetest_challenge_path = geetest_challenge_path
|
||||
"""极验验证challenge的路径"""
|
||||
self.geetest_result_path = geetest_result_path
|
||||
"""极验验证返回参数的路径"""
|
||||
self.get_geetest_url = get_geetest_url
|
||||
"""获取极验验证结果的URL"""
|
||||
self.get_geetest_method = get_geetest_method
|
||||
|
Loading…
Reference in New Issue
Block a user