From ab664e4da8c652fd998c5934d180fb5e20236e91 Mon Sep 17 00:00:00 2001 From: Your Name Date: Tue, 23 Jun 2026 19:05:07 +0800 Subject: [PATCH] fix countdown digit extraction regression --- douyin/fudai/douyin_fudai_core_pkg/countdown_parse.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/douyin/fudai/douyin_fudai_core_pkg/countdown_parse.py b/douyin/fudai/douyin_fudai_core_pkg/countdown_parse.py index 2e28900..ce87444 100644 --- a/douyin/fudai/douyin_fudai_core_pkg/countdown_parse.py +++ b/douyin/fudai/douyin_fudai_core_pkg/countdown_parse.py @@ -9,6 +9,10 @@ def extract_countdown_digits(text: str, max_digits: int = 2) -> str: normalized = raw.translate(str.maketrans({"O": "0", "o": "0", "U": "0", "u": "0"})) digits = "".join(ch for ch in normalized if ch.isdigit()) if len(digits) > max_digits: + candidate = digits[:max_digits] + if set(candidate) == {"0"} and digits.lstrip("0"): + actual = digits.lstrip("0")[:max_digits] + return actual.zfill(max_digits) # 倒计时分钟/秒区域偶发会混入噪声数字(如 "601"、"0123")。 # 对 2 位提取场景,优先尝试滑窗中第一个“合法”候选(00~59), # 若都不合法再回退到原有左侧截取策略。 @@ -21,10 +25,6 @@ def extract_countdown_digits(text: str, max_digits: int = 2) -> str: continue if 0 <= v <= 59: return win - candidate = digits[:max_digits] - if set(candidate) == {"0"} and digits.lstrip("0"): - actual = digits.lstrip("0")[:max_digits] - return actual.zfill(max_digits) return candidate if len(digits) == 1: return "0" + digits