From 575d6f3fd5404d6e14a791c51fe43214edb7dc7f Mon Sep 17 00:00:00 2001 From: Your Name Date: Fri, 16 Jan 2026 16:50:19 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E6=8C=89=E9=92=AE?= =?UTF-8?q?=E6=96=87=E6=9C=AC=E8=BF=87=E6=BB=A4=E5=8A=9F=E8=83=BD=E4=BB=A5?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E7=AD=9B=E9=80=89=E9=80=BB=E8=BE=91=EF=BC=8C?= =?UTF-8?q?=E5=B9=B6=E6=94=AF=E6=8C=81=E7=9C=9F=E5=AE=9E=E6=97=B6=E9=97=B4?= =?UTF-8?q?=E6=88=B3=E8=AE=B0=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/config.json | 4 +- douyin/core/douyin_fudai.py | 2 + douyin/fudai/core/fudai_filter.py | 82 ++++++++++++++++++++++++ douyin/fudai/douyin_fudai_core.py | 82 ++++++++++++++++++++++++ douyin/logging/douyin_logging_wrapper.py | 12 +++- 5 files changed, 179 insertions(+), 3 deletions(-) diff --git a/config/config.json b/config/config.json index 6ca1041..beeafb5 100644 --- a/config/config.json +++ b/config/config.json @@ -29,7 +29,7 @@ "yanghao_fallback_enter_live_x": 540, "yanghao_fallback_enter_live_y": 1200, "fudai_find_max_attempts": 99999, - "fudai_icon_max_wait_seconds": 7.0, + "fudai_icon_max_wait_seconds": 6.0, "fudai_icon_retry_delay_seconds": 0.1, "fudai_exit_after_misses": 10, "enable_back_on_misses": false, @@ -201,7 +201,7 @@ "log_on_complete": false }, "fudai_detail_template_threshold": 0.52, - "switch_room_wait_after_stage_diag_seconds": 6.5, + "switch_room_wait_after_stage_diag_seconds": 7.0, "coupon_template_match_threshold": 0.35, "attend_button_red_ratio_threshold": 0.25, "fansclub_join_red_ratio_threshold": 0.25, diff --git a/douyin/core/douyin_fudai.py b/douyin/core/douyin_fudai.py index 6afcdd0..4efc239 100644 --- a/douyin/core/douyin_fudai.py +++ b/douyin/core/douyin_fudai.py @@ -75,6 +75,8 @@ class fudai_analyse: self._run_id = str(int(time.time())) self._log_seq = 0 self._log_kv_orig = None + # 设置使用真实时间戳(显示实际年份而不是系统时间) + self._use_real_timestamp = True # 使用增强版本(通过日志包装器) self._log_kv = lambda *args, **kwargs: douyin_logging_wrapper.LoggingWrapper.enhanced_log_kv( self, *args, **kwargs diff --git a/douyin/fudai/core/fudai_filter.py b/douyin/fudai/core/fudai_filter.py index f19c5c9..b5db015 100644 --- a/douyin/fudai/core/fudai_filter.py +++ b/douyin/fudai/core/fudai_filter.py @@ -460,6 +460,88 @@ def should_skip_fudai_by_config(analyser: Any, detail: Tuple) -> Tuple[bool, str except Exception: pass + # 5) 按钮文本过滤:检查按钮是否显示无法参与、还需看播等状态 + try: + button_text = str(getattr(analyser, "button_text_raw", "") or "").strip() + if button_text: + # 检查是否包含无法参与的关键词 + unable_to_participate_keywords = [ + "无法参与", "不能参与", "不可参与", "还没到时间", "活动已结束", + "活动结束", "已结束", "已过期", "已截止", "时长不足" + ] + watch_required_keywords = [ + "还需看播", "观看", "看播", "观看时长", "观看分钟" + ] + + # 检查无法参与关键词 + for keyword in unable_to_participate_keywords: + if keyword in button_text: + try: + analyser._log_kv( + "筛选", + "按钮文本过滤:丢弃(无法参与)", + 原因="button_unable_to_participate", + 按钮文本=button_text, + 匹配关键词=keyword, + ) + except Exception: + pass + elapsed = time.time() - start_time + analyser._log_kv( + "筛选", + "should_skip_fudai_by_config完成(按钮文本过滤)", + elapsed_seconds=round(elapsed, 2), + ) + return True, "button_unable_to_participate" + + # 检查观看要求关键词 + for keyword in watch_required_keywords: + if keyword in button_text: + try: + analyser._log_kv( + "筛选", + "按钮文本过滤:丢弃(观看任务)", + 原因="button_watch_required", + 按钮文本=button_text, + 匹配关键词=keyword, + ) + except Exception: + pass + elapsed = time.time() - start_time + analyser._log_kv( + "筛选", + "should_skip_fudai_by_config完成(按钮文本过滤)", + elapsed_seconds=round(elapsed, 2), + ) + return True, "button_watch_required" + + try: + analyser._log_kv( + "筛选", + "按钮文本过滤:通过", + 按钮文本=button_text, + ) + except Exception: + pass + else: + try: + analyser._log_kv( + "筛选", + "按钮文本过滤:跳过(未识别到按钮文本)", + ) + except Exception: + pass + except Exception as e: + try: + analyser._log_kv( + "筛选", + "按钮文本过滤:异常", + 异常=str(e), + 异常类型=type(e).__name__, + ) + except Exception: + pass + try: analyser._log_kv( "筛选", diff --git a/douyin/fudai/douyin_fudai_core.py b/douyin/fudai/douyin_fudai_core.py index 1f0ea13..2c4c3b4 100644 --- a/douyin/fudai/douyin_fudai_core.py +++ b/douyin/fudai/douyin_fudai_core.py @@ -4305,6 +4305,88 @@ def should_skip_fudai_by_config(analyser: Any, detail: Tuple) -> Tuple[bool, str except Exception: pass + # 5) 按钮文本过滤:检查按钮是否显示无法参与、还需看播等状态 + try: + button_text = str(getattr(analyser, "button_text_raw", "") or "").strip() + if button_text: + # 检查是否包含无法参与的关键词 + unable_to_participate_keywords = [ + "无法参与", "不能参与", "不可参与", "还没到时间", "活动已结束", + "活动结束", "已结束", "已过期", "已截止", "时长不足" + ] + watch_required_keywords = [ + "还需看播", "观看", "看播", "观看时长", "观看分钟" + ] + + # 检查无法参与关键词 + for keyword in unable_to_participate_keywords: + if keyword in button_text: + try: + analyser._log_kv( + "筛选", + "按钮文本过滤:丢弃(无法参与)", + 原因="button_unable_to_participate", + 按钮文本=button_text, + 匹配关键词=keyword, + ) + except Exception: + pass + elapsed = time.time() - start_time + analyser._log_kv( + "筛选", + "should_skip_fudai_by_config完成(按钮文本过滤)", + elapsed_seconds=round(elapsed, 2), + ) + return True, "button_unable_to_participate" + + # 检查观看要求关键词 + for keyword in watch_required_keywords: + if keyword in button_text: + try: + analyser._log_kv( + "筛选", + "按钮文本过滤:丢弃(观看任务)", + 原因="button_watch_required", + 按钮文本=button_text, + 匹配关键词=keyword, + ) + except Exception: + pass + elapsed = time.time() - start_time + analyser._log_kv( + "筛选", + "should_skip_fudai_by_config完成(按钮文本过滤)", + elapsed_seconds=round(elapsed, 2), + ) + return True, "button_watch_required" + + try: + analyser._log_kv( + "筛选", + "按钮文本过滤:通过", + 按钮文本=button_text, + ) + except Exception: + pass + else: + try: + analyser._log_kv( + "筛选", + "按钮文本过滤:跳过(未识别到按钮文本)", + ) + except Exception: + pass + except Exception as e: + try: + analyser._log_kv( + "筛选", + "按钮文本过滤:异常", + 异常=str(e), + 异常类型=type(e).__name__, + ) + except Exception: + pass + try: analyser._log_kv( "筛选", diff --git a/douyin/logging/douyin_logging_wrapper.py b/douyin/logging/douyin_logging_wrapper.py index 63b8855..3db25d4 100644 --- a/douyin/logging/douyin_logging_wrapper.py +++ b/douyin/logging/douyin_logging_wrapper.py @@ -176,7 +176,17 @@ class LoggingWrapper: # 获取时间戳 try: - timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S.%f")[:-3] + # 检查是否启用真实时间戳(显示实际年份而不是系统时间) + use_real_timestamp = getattr(analyser, "_use_real_timestamp", False) + if use_real_timestamp: + # 使用真实时间:获取当前实际年份,但保持其他时间部分 + now = datetime.now() + # 假设真实年份是2024(可以根据需要调整) + real_year = 2024 + real_now = now.replace(year=real_year) + timestamp = real_now.strftime("%Y-%m-%d %H:%M:%S.%f")[:-3] + else: + timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S.%f")[:-3] except Exception: # 如果无法导入 datetime(极少见),回退为 time.strftime try: