fix: preserve fudai detail countdown detection

This commit is contained in:
Your Name committed 2026-06-23 11:22:23 +08:00
1 parent 77413fa7d1
commit 4af2adc4d6
3 files changed
+85 -1

No files matched your search

+1 -1
View File
@@ -211,7 +211,7 @@ def _apply_region_overrides(defaults: dict[str, Any], overrides: Any) -> dict[st
parsed = _tuple4(candidate)
if parsed is not None:
merged[key] = parsed
else:
elif key in overrides and candidate is not None:
merged[key] = candidate
return merged
+61
View File
@@ -537,6 +537,36 @@ def _normalize_countdown_pair(mm_raw: Any, ss_raw: Any) -> Tuple[str, str]:
return "", ""
def _apply_countdown_text_fallback(
analyser: Any,
countdown_mm_raw: Any,
countdown_ss_raw: Any,
sources: Tuple[Tuple[str, Any], ...],
) -> Tuple[Any, Any]:
"""Use already-recognized text as a cheap countdown fallback before extra OCR."""
mm_norm, ss_norm = _normalize_countdown_pair(countdown_mm_raw, countdown_ss_raw)
if mm_norm and ss_norm:
return countdown_mm_raw, countdown_ss_raw
for source_name, source_text in sources:
mm_text, ss_text = _parse_mmss_from_full_text(source_text)
if not (mm_text and ss_text):
continue
if _detail_verbose_logs(analyser):
try:
analyser._log_kv(
"倒计时",
"已有OCR文本命中倒计时fallback",
source=source_name,
text=str(source_text or "")[:80],
mm=mm_text,
ss=ss_text,
)
except Exception:
pass
return mm_text, ss_text
return countdown_mm_raw, countdown_ss_raw
def _select_countdown_from_candidates(
analyser: Any,
candidate_meta: List[Dict[str, Any]],
@@ -1100,6 +1130,17 @@ def get_fudai_contain(analyser, renwu: int = 2) -> Tuple[str, str, int, int, flo
)
except Exception:
pass
countdown_mm_raw, countdown_ss_raw = _apply_countdown_text_fallback(
analyser,
countdown_mm_raw,
countdown_ss_raw,
(
("content", fudai_content_raw),
("value", value_raw),
("info_line", info_line_raw),
("countdown_full", countdown_full_raw),
),
)
if picked:
picked_idx = int(picked.get("idx", -1))
if _detail_verbose_logs(analyser):
@@ -1219,6 +1260,16 @@ def get_fudai_contain(analyser, renwu: int = 2) -> Tuple[str, str, int, int, flo
mm_full_h, ss_full_h = _parse_mmss_from_full_text(countdown_full_raw)
if countdown_full_ocr_in_critical_path and mm_full_h and ss_full_h:
countdown_mm_raw, countdown_ss_raw = mm_full_h, ss_full_h
countdown_mm_raw, countdown_ss_raw = _apply_countdown_text_fallback(
analyser,
countdown_mm_raw,
countdown_ss_raw,
(
("content", fudai_content_raw),
("value", value_raw),
("countdown_full", countdown_full_raw),
),
)
if picked_heavy:
picked_heavy_idx = int(picked_heavy.get("idx", -1))
if _detail_verbose_logs(analyser):
@@ -1487,6 +1538,16 @@ def get_fudai_contain(analyser, renwu: int = 2) -> Tuple[str, str, int, int, flo
mm_fb, ss_fb = _parse_mmss_from_full_text(countdown_full_raw_fb)
if countdown_full_ocr_in_critical_path and mm_fb and ss_fb:
countdown_mm_raw, countdown_ss_raw = mm_fb, ss_fb
countdown_mm_raw, countdown_ss_raw = _apply_countdown_text_fallback(
analyser,
countdown_mm_raw,
countdown_ss_raw,
(
("content", fudai_content_raw),
("value", value_raw),
("countdown_full", countdown_full_raw_fb),
),
)
if picked_fb:
picked_fb_idx = int(picked_fb.get("idx", -1))
if _detail_verbose_logs(analyser):
+23
View File
@@ -79,6 +79,9 @@ def test_detail_profile_prefers_config_overrides(monkeypatch):
assert legacy["button"] == (101, 202, 303, 404)
assert v2_two["content"] == (1, 2, 3, 4)
assert v2_two["version"] == "v2_0"
assert v2_one["version"] == "v2_0"
assert legacy["version"] == "legacy"
assert v2_one["info_line"] == (11, 22, 33, 44)
assert lottery["pixel"] == (7, 8, 9, 10)
assert lottery["click"] == (66, 77)
@@ -350,6 +353,26 @@ def test_countdown_full_ocr_critical_path_requires_explicit_opt_in(monkeypatch):
assert _should_schedule_countdown_full_ocr(analyser, disabled_switches) is False
def test_countdown_text_fallback_uses_existing_ocr_without_extra_ocr():
from douyin.fudai.douyin_fudai_contain_impl import (
_apply_countdown_text_fallback,
)
analyser = SimpleNamespace(fudai_detail_verbose_logs=False)
mm, ss = _apply_countdown_text_fallback(
analyser,
"",
"",
(
("content", "免费购129人已参与00 : 00后开奖"),
("value", ""),
),
)
assert (mm, ss) == ("00", "00")
def test_info_line_ocr_is_not_in_detail_critical_path_by_default(monkeypatch):
from douyin.fudai.douyin_fudai_contain_impl import (
_should_schedule_info_line_ocr,