diff --git a/douyin/fudai/core/fudai_detail_validator.py b/douyin/fudai/core/fudai_detail_validator.py index c28dc0c..d29d4c5 100644 --- a/douyin/fudai/core/fudai_detail_validator.py +++ b/douyin/fudai/core/fudai_detail_validator.py @@ -54,37 +54,29 @@ def validate_fudai_detail(detail: Tuple, analyser: Any = None) -> Tuple[bool, st # 检查1:内容不能为空(至少要有一些文字) # 如果运行时显式禁用了内容识别,则跳过此检查(允许内容为空) - try: - disable_content = False - if analyser: + disable_content = False + if analyser: + try: disable_content = bool( getattr(analyser, "fudai_disable_content_recognition", False) ) - # 如果 analyser 未设置该属性,再尝试从 config.json 读取全局配置 - if not disable_content: - try: - cfg_path = path_config.get_config_path() - if cfg_path and os.path.exists(cfg_path): - with open(cfg_path, "r", encoding="utf-8") as f: - cfg = json.load(f) - disable_content = bool( - cfg.get("fudai_disable_content_recognition", False) - ) - except Exception: - pass - if not disable_content: - if not content or len(content.strip()) < 2: - # 内容为空但价值和倒计时都合理时,不应判定失败(部分福袋确实无文字内容) - if prize_value_yuan > 0 and countdown_end is not None and countdown_end > 0: - pass - else: - return False, "content_empty_or_too_short" - except Exception: + except Exception: + pass + if not disable_content: + try: + cfg_path = path_config.get_config_path() + if cfg_path and os.path.exists(cfg_path): + with open(cfg_path, "r", encoding="utf-8") as f: + cfg = json.load(f) + disable_content = bool( + cfg.get("fudai_disable_content_recognition", False) + ) + except Exception: + pass + + if not disable_content: if not content or len(content.strip()) < 2: - if prize_value_yuan > 0 and countdown_end is not None and countdown_end > 0: - pass - else: - return False, "content_empty_or_too_short" + return False, "content_empty_or_too_short" # 检查2:价值应该大于0(福袋至少应该有价值) if prize_value_yuan <= 0: