diff --git a/douyin/core/douyin_fudai.py b/douyin/core/douyin_fudai.py index eeaad1e..6b8c9c8 100644 --- a/douyin/core/douyin_fudai.py +++ b/douyin/core/douyin_fudai.py @@ -2410,18 +2410,11 @@ class fudai_analyse: pass # 清除任务数量标志 - try: - self._fudai_detail_task_count_from_stage = None - try: - self._log_kv( - "福袋详情", - "_handle_in_fudai_detail:清除任务数量标志", - log_type="DEBUG", - ) - except Exception: - pass - except Exception: - pass + from douyin.core.fudai_modules.fudai_detail_helpers import ( + clear_task_count_flag, + ) + + clear_task_count_flag(self) # 步骤1结束计时 step1_elapsed = (time.time() - step1_start) * 1000 @@ -2487,18 +2480,7 @@ class fudai_analyse: ) # 清除任务数量标志 - try: - self._fudai_detail_task_count_from_stage = None - try: - self._log_kv( - "福袋详情", - "_handle_in_fudai_detail:清除任务数量标志", - log_type="DEBUG", - ) - except Exception: - pass - except Exception: - pass + clear_task_count_flag(self) elapsed = time.time() - start_time self._log_kv( @@ -2759,18 +2741,7 @@ class fudai_analyse: pass # 清除任务数量标志 - try: - self._fudai_detail_task_count_from_stage = None - try: - self._log_kv( - "福袋详情", - "_handle_in_fudai_detail:清除任务数量标志", - log_type="DEBUG", - ) - except Exception: - pass - except Exception: - pass + clear_task_count_flag(self) elapsed = time.time() - start_time self._log_kv( @@ -2834,18 +2805,7 @@ class fudai_analyse: pass # 清除任务数量标志 - try: - self._fudai_detail_task_count_from_stage = None - try: - self._log_kv( - "福袋详情", - "_handle_in_fudai_detail:清除任务数量标志", - log_type="DEBUG", - ) - except Exception: - pass - except Exception: - pass + clear_task_count_flag(self) elapsed = time.time() - start_time self._log_kv( @@ -2864,18 +2824,7 @@ class fudai_analyse: pass # 清除任务数量标志 - try: - self._fudai_detail_task_count_from_stage = None - try: - self._log_kv( - "福袋详情", - "_handle_in_fudai_detail:清除任务数量标志", - log_type="DEBUG", - ) - except Exception: - pass - except Exception: - pass + clear_task_count_flag(self) elapsed = time.time() - start_time self._log_kv( @@ -2894,18 +2843,7 @@ class fudai_analyse: pass # 清除任务数量标志 - try: - self._fudai_detail_task_count_from_stage = None - try: - self._log_kv( - "福袋详情", - "_handle_in_fudai_detail:清除任务数量标志", - log_type="DEBUG", - ) - except Exception: - pass - except Exception: - pass + clear_task_count_flag(self) elapsed = time.time() - start_time self._log_kv( @@ -3027,18 +2965,7 @@ class fudai_analyse: pass # 清除任务数量标志 - try: - self._fudai_detail_task_count_from_stage = None - try: - self._log_kv( - "福袋详情", - "_handle_in_fudai_detail:清除任务数量标志", - log_type="DEBUG", - ) - except Exception: - pass - except Exception: - pass + clear_task_count_flag(self) elapsed = time.time() - start_time self._log_kv( @@ -3058,18 +2985,7 @@ class fudai_analyse: pass # 清除任务数量标志 - try: - self._fudai_detail_task_count_from_stage = None - try: - self._log_kv( - "福袋详情", - "_handle_in_fudai_detail:清除任务数量标志", - log_type="DEBUG", - ) - except Exception: - pass - except Exception: - pass + clear_task_count_flag(self) elapsed = time.time() - start_time self._log_kv( @@ -3113,18 +3029,7 @@ class fudai_analyse: douyin_fudai_detail.close_fudai_detail(self) # 清除任务数量标志 - try: - self._fudai_detail_task_count_from_stage = None - try: - self._log_kv( - "福袋详情", - "_handle_in_fudai_detail:清除任务数量标志", - log_type="DEBUG", - ) - except Exception: - pass - except Exception: - pass + clear_task_count_flag(self) elapsed = time.time() - start_time self._log_kv( @@ -3153,18 +3058,7 @@ class fudai_analyse: pass # 清除任务数量标志 - try: - self._fudai_detail_task_count_from_stage = None - try: - self._log_kv( - "福袋详情", - "_handle_in_fudai_detail:清除任务数量标志", - log_type="DEBUG", - ) - except Exception: - pass - except Exception: - pass + clear_task_count_flag(self) elapsed = time.time() - start_time self._log_kv( @@ -3211,18 +3105,7 @@ class fudai_analyse: pass # 清除任务数量标志 - try: - self._fudai_detail_task_count_from_stage = None - try: - self._log_kv( - "福袋详情", - "_handle_in_fudai_detail:清除任务数量标志", - log_type="DEBUG", - ) - except Exception: - pass - except Exception: - pass + clear_task_count_flag(self) elapsed = time.time() - start_time self._log_kv( @@ -3429,18 +3312,7 @@ class fudai_analyse: pass # 清除任务数量标志 - try: - self._fudai_detail_task_count_from_stage = None - try: - self._log_kv( - "福袋详情", - "_handle_in_fudai_detail:清除任务数量标志", - log_type="DEBUG", - ) - except Exception: - pass - except Exception: - pass + clear_task_count_flag(self) # 返回,让主循环只检测开奖结果,不执行其他操作 # 步骤4结束计时 diff --git a/douyin/core/fudai_modules/fudai_detail_helpers.py b/douyin/core/fudai_modules/fudai_detail_helpers.py index 3585815..8960198 100644 --- a/douyin/core/fudai_modules/fudai_detail_helpers.py +++ b/douyin/core/fudai_modules/fudai_detail_helpers.py @@ -5,6 +5,26 @@ from __future__ import annotations +def clear_task_count_flag(analyser) -> None: + """清除任务数量标志(_fudai_detail_task_count_from_stage = None)。 + + 在 _handle_in_fudai_detail 多个早返回路径中重复出现的清理逻辑, + 统一抽到这里避免重复。 + """ + try: + analyser._fudai_detail_task_count_from_stage = None + try: + analyser._log_kv( + "福袋详情", + "_handle_in_fudai_detail:清除任务数量标志", + log_type="DEBUG", + ) + except Exception: + pass + except Exception: + pass + + def handle_consecutive_failures_exceeded(analyser, max_consecutive_failures: int) -> None: """连续参与失败次数过多:关闭详情页、按需切换直播间、重置计数器。