fix one-task countdown box root cause
This commit is contained in:
1 parent
ed0aca5f28
commit
dc34b7484b
4 files changed
+57
-13
No files matched your search
@@ -138,7 +138,7 @@ DETAIL_UI_V2_0_ONE_TASK = {
|
||||
"variant": "one_task",
|
||||
"content": (360, 1460, 1035, 1545),
|
||||
"value": (350, 1640, 760, 1735),
|
||||
"countdown_full": (730, 1338, 1038, 1418),
|
||||
"countdown_full": (700, 1320, 930, 1415),
|
||||
"info_line": (430, 1315, 1055, 1435),
|
||||
"task_list": (60, 1845, 885, 2005),
|
||||
"task_count": (890, 1855, 1040, 1960),
|
||||
@@ -164,6 +164,15 @@ STALE_DETAIL_REGION_DEFAULTS = {
|
||||
},
|
||||
}
|
||||
|
||||
STALE_DETAIL_REGION_OVERRIDES = {
|
||||
"v2_0_one_task": {
|
||||
"countdown_full": (
|
||||
(730, 1338, 1038, 1418),
|
||||
(769, 1384, 1029, 1442),
|
||||
),
|
||||
},
|
||||
}
|
||||
|
||||
PIXEL_REGION_DEFAULTS = {
|
||||
"lottery_result": {
|
||||
"button": LOTTERY_RESULT_CONFIRM_BUTTON_V2,
|
||||
@@ -221,13 +230,20 @@ def _apply_region_overrides(defaults: dict[str, Any], overrides: Any) -> dict[st
|
||||
|
||||
def _drop_stale_region_overrides(profile_key: str, overrides: dict[str, Any]) -> dict[str, Any]:
|
||||
stale = STALE_DETAIL_REGION_DEFAULTS.get(profile_key, {})
|
||||
if not stale:
|
||||
stale_overrides = STALE_DETAIL_REGION_OVERRIDES.get(profile_key, {})
|
||||
if not stale and not stale_overrides:
|
||||
return dict(overrides)
|
||||
cleaned = dict(overrides)
|
||||
for key, old_value in stale.items():
|
||||
parsed = _tuple4(cleaned.get(key))
|
||||
if parsed is not None and parsed == tuple(old_value):
|
||||
cleaned.pop(key, None)
|
||||
for key, old_values in stale_overrides.items():
|
||||
parsed = _tuple4(cleaned.get(key))
|
||||
if parsed is None:
|
||||
continue
|
||||
if any(parsed == tuple(old_value) for old_value in old_values):
|
||||
cleaned.pop(key, None)
|
||||
return cleaned
|
||||
|
||||
|
||||
|
||||
@@ -69,12 +69,20 @@ def cut_detail_regions(
|
||||
w = max(1, int(x2 - x1))
|
||||
h = max(1, int(y2 - y1))
|
||||
if x1 >= 700:
|
||||
digit_y1 = min(y2 - 2, y1 + max(1, int(h * 0.44)))
|
||||
digit_y2 = y2
|
||||
mm_x1 = min(x2 - 1, x1 + max(1, int(w * 0.12)))
|
||||
mm_x2 = min(x2, max(mm_x1 + 1, x1 + max(2, int(w * 0.36))))
|
||||
ss_x1 = min(x2 - 1, x1 + max(1, int(w * 0.42)))
|
||||
ss_x2 = min(x2, max(ss_x1 + 1, x1 + max(2, int(w * 0.68))))
|
||||
if renwu == 1:
|
||||
digit_y1 = min(y2 - 2, y1 + max(1, int(h * 0.28)))
|
||||
digit_y2 = min(y2, max(digit_y1 + 2, y1 + max(2, int(h * 0.96))))
|
||||
mm_x1 = min(x2 - 1, x1 + max(1, int(w * 0.08)))
|
||||
mm_x2 = min(x2, max(mm_x1 + 1, x1 + max(2, int(w * 0.31))))
|
||||
ss_x1 = min(x2 - 1, x1 + max(1, int(w * 0.48)))
|
||||
ss_x2 = min(x2, max(ss_x1 + 1, x1 + max(2, int(w * 0.71))))
|
||||
else:
|
||||
digit_y1 = min(y2 - 2, y1 + max(1, int(h * 0.44)))
|
||||
digit_y2 = y2
|
||||
mm_x1 = min(x2 - 1, x1 + max(1, int(w * 0.12)))
|
||||
mm_x2 = min(x2, max(mm_x1 + 1, x1 + max(2, int(w * 0.36))))
|
||||
ss_x1 = min(x2 - 1, x1 + max(1, int(w * 0.42)))
|
||||
ss_x2 = min(x2, max(ss_x1 + 1, x1 + max(2, int(w * 0.68))))
|
||||
else:
|
||||
# 旧布局不带左上调试标签,保留历史切法。
|
||||
digit_y1 = min(y2 - 2, y1 + max(1, int(h * 0.34)))
|
||||
|
||||
@@ -149,14 +149,14 @@ class TestCutDetailRegions:
|
||||
|
||||
def test_one_task_profile_countdown_box_uses_new_coords(self):
|
||||
a = _mk_analyser()
|
||||
profile = {"countdown_full": (730, 1338, 1038, 1418)}
|
||||
profile = {"countdown_full": (700, 1320, 930, 1415)}
|
||||
result = cut_detail_regions(a, renwu=1, profile=profile)
|
||||
assert result == (730, 1338, 1038, 1418)
|
||||
assert result == (700, 1320, 930, 1415)
|
||||
|
||||
mm_call = a.cut_pic.call_args_list[1]
|
||||
ss_call = a.cut_pic.call_args_list[2]
|
||||
assert mm_call.args[:4] == (766, 1373, 840, 1418)
|
||||
assert ss_call.args[:4] == (859, 1373, 939, 1418)
|
||||
assert mm_call.args[:4] == (718, 1346, 771, 1411)
|
||||
assert ss_call.args[:4] == (810, 1346, 863, 1411)
|
||||
|
||||
def test_renwu_3_uses_correct_box(self):
|
||||
a = _mk_analyser()
|
||||
|
||||
@@ -37,7 +37,7 @@ def test_v2_profile_keeps_legacy_and_adds_expected_regions(monkeypatch):
|
||||
assert DETAIL_UI_V2_0["button"] == (70, 2020, 1010, 2165)
|
||||
assert DETAIL_UI_V2_0_ONE_TASK["content"] == (360, 1460, 1035, 1545)
|
||||
assert DETAIL_UI_V2_0_ONE_TASK["value"] == (350, 1640, 760, 1735)
|
||||
assert DETAIL_UI_V2_0_ONE_TASK["countdown_full"] == (730, 1338, 1038, 1418)
|
||||
assert DETAIL_UI_V2_0_ONE_TASK["countdown_full"] == (700, 1320, 930, 1415)
|
||||
assert DETAIL_UI_V2_0_ONE_TASK["info_line"] == (430, 1315, 1055, 1435)
|
||||
assert DETAIL_UI_V2_0_ONE_TASK["task_list"] == (60, 1845, 885, 2005)
|
||||
assert DETAIL_UI_V2_0_ONE_TASK["task_count"] == (890, 1855, 1040, 1960)
|
||||
@@ -150,6 +150,26 @@ def test_detail_profile_ignores_stale_v2_one_task_narrow_countdown(monkeypatch):
|
||||
assert profile["countdown_full"] == coords.DETAIL_UI_V2_0_ONE_TASK["countdown_full"]
|
||||
|
||||
|
||||
def test_detail_profile_ignores_previous_default_v2_one_task_countdown(monkeypatch):
|
||||
from douyin.fudai.core import coords
|
||||
|
||||
monkeypatch.setattr(
|
||||
coords,
|
||||
"_read_runtime_region_config",
|
||||
lambda: {
|
||||
"fudai_detail_regions": {
|
||||
"v2_0_one_task": {
|
||||
"countdown_full": [730, 1338, 1038, 1418],
|
||||
}
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
profile = coords.get_fudai_detail_profile("v2_0", task_count=1)
|
||||
|
||||
assert profile["countdown_full"] == coords.DETAIL_UI_V2_0_ONE_TASK["countdown_full"]
|
||||
|
||||
|
||||
def test_v2_two_task_profile_covers_batu_4999_sample_regions():
|
||||
from PIL import Image
|
||||
from pathlib import Path
|
||||
|
||||
Reference in new issue
Block a user