fix countdown frame fallback

This commit is contained in:
Your Name committed 2026-06-23 19:54:40 +08:00
1 parent 3ace80dcca
commit a2a899bb9f
5 files changed
+74 -25

No files matched your search

@@ -1,8 +1,10 @@
from __future__ import annotations
from types import SimpleNamespace
from unittest.mock import MagicMock
from douyin.fudai.douyin_fudai_contain_impl import (
_apply_countdown_text_fallback,
_build_countdown_candidate_boxes,
_parse_mmss_from_full_text,
_select_countdown_from_candidates,
@@ -194,3 +196,37 @@ def test_parse_mmss_from_full_text_ignores_non_countdown_text():
mm, ss = _parse_mmss_from_full_text("直播间,否则会失去抽奖机会")
assert mm == ""
assert ss == ""
def test_parse_mmss_from_full_text_ignores_product_model_digits_without_countdown_hint():
mm, ss = _parse_mmss_from_full_text("G4939-敦煌飞天帝王黄茶叶罐")
assert mm == ""
assert ss == ""
def test_countdown_text_fallback_ignores_content_product_digits_without_countdown_hint():
analyser = SimpleNamespace(fudai_detail_verbose_logs=False)
mm, ss = _apply_countdown_text_fallback(
analyser,
"",
"",
(("content", "G4939-敦煌飞天帝王黄茶叶罐"),),
)
assert mm == ""
assert ss == ""
def test_countdown_text_fallback_does_not_use_content_even_with_countdown_text():
analyser = SimpleNamespace(fudai_detail_verbose_logs=False)
mm, ss = _apply_countdown_text_fallback(
analyser,
"",
"",
(("content", "免费购129人已参与00 : 00后开奖"),),
)
assert mm == ""
assert ss == ""
+15 -8
View File
@@ -96,7 +96,7 @@ class TestCutDetailRegions:
assert ss_call.args[0] == ss_x1
assert ss_call.args[2] == ss_x2
def test_profile_countdown_vertical_crop_is_narrower_and_higher(self):
def test_profile_countdown_vertical_crop_skips_left_label_for_v2_chip(self):
a = _mk_analyser()
profile = {"countdown_full": (760, 1328, 1038, 1398)}
@@ -104,12 +104,10 @@ class TestCutDetailRegions:
mm_call = a.cut_pic.call_args_list[1]
ss_call = a.cut_pic.call_args_list[2]
assert mm_call.args[1] == 1351
assert mm_call.args[3] == 1392
assert ss_call.args[1] == 1351
assert ss_call.args[3] == 1392
assert mm_call.args[:4] == (793, 1358, 860, 1398)
assert ss_call.args[:4] == (876, 1358, 949, 1398)
def test_v2_two_task_tall_profile_uses_lower_digit_band(self):
def test_v2_two_task_tall_profile_skips_left_label_and_uses_lower_digit_band(self):
a = _mk_analyser()
profile = {"countdown_full": (760, 1265, 1040, 1398)}
@@ -117,8 +115,12 @@ class TestCutDetailRegions:
mm_call = a.cut_pic.call_args_list[1]
ss_call = a.cut_pic.call_args_list[2]
assert mm_call.args[1] >= 1310
assert mm_call.args[3] >= 1385
assert mm_call.args[0] == 793
assert mm_call.args[2] == 860
assert ss_call.args[0] == 877
assert ss_call.args[2] == 950
assert mm_call.args[1] >= 1323
assert mm_call.args[3] == 1398
assert ss_call.args[1] == mm_call.args[1]
assert ss_call.args[3] == mm_call.args[3]
@@ -151,6 +153,11 @@ class TestCutDetailRegions:
result = cut_detail_regions(a, renwu=1, profile=profile)
assert result == (730, 1338, 1038, 1418)
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)
def test_renwu_3_uses_correct_box(self):
a = _mk_analyser()
from douyin.fudai.core.coords import COUNTDOWN_1010_1130
+2 -2
View File
@@ -385,8 +385,8 @@ def test_countdown_text_fallback_uses_existing_ocr_without_extra_ocr():
"",
"",
(
("content", "免费购129人已参与00 : 00后开奖"),
("value", ""),
("info_line", "免费购129人已参与00 : 00后开奖"),
("countdown_full", ""),
),
)