diff --git a/douyin/core/douyin_fudai.py b/douyin/core/douyin_fudai.py index 77e7dca..848be9e 100644 --- a/douyin/core/douyin_fudai.py +++ b/douyin/core/douyin_fudai.py @@ -1258,16 +1258,11 @@ class fudai_analyse: attend_before_ts = getattr(self, "_last_successful_attend_ts", 0.0) or 0.0 # 记录当前福袋的 future_ts,供 attend_choujiang 使用 - try: - if isinstance(detail, tuple) and len(detail) >= 6: - d_cast: Tuple[Any, ...] = cast(Tuple[Any, ...], detail) - countdown_tuple = d_cast[5] - if isinstance(countdown_tuple, (tuple, list)) and len(countdown_tuple) >= 2: - future_ts = float(countdown_tuple[1] or 0.0) - if future_ts > 0: - self._current_fudai_future_ts = future_ts - except Exception: - pass + from douyin.core.fudai_modules.fudai_detail_helpers import ( + extract_future_ts_from_detail, + ) + + extract_future_ts_from_detail(self, detail) # 重置详情关闭标志 try: @@ -1283,20 +1278,11 @@ class fudai_analyse: step4_start = time.time() # 执行参与决策 if detail is None: - try: - self._log_kv("参与", "详情数据为 None,无法执行参与决策") - except Exception: - pass - - # 清除任务数量标志 - clear_task_count_flag(self) - - elapsed = time.time() - start_time - self._log_kv( - "流程", - "_handle_in_fudai_detail完成(详情为None)", - elapsed_seconds=round(elapsed, 2), + from douyin.core.fudai_modules.fudai_detail_helpers import ( + handle_detail_none_in_step4, ) + + handle_detail_none_in_step4(self, start_time) return join_result = douyin_fudai_core.basic_join_decision( self, detail, (skip, skip_reason) diff --git a/douyin/core/fudai_modules/fudai_detail_helpers.py b/douyin/core/fudai_modules/fudai_detail_helpers.py index e10f525..1a3aa5f 100644 --- a/douyin/core/fudai_modules/fudai_detail_helpers.py +++ b/douyin/core/fudai_modules/fudai_detail_helpers.py @@ -42,6 +42,40 @@ def log_screenshot_failed( pass +def extract_future_ts_from_detail(analyser, detail) -> None: + """从 detail tuple 中提取倒计时 future_ts 并写入 _current_fudai_future_ts。""" + try: + countdown_tuple = None + if isinstance(detail, tuple) and len(detail) >= 6: + countdown_tuple = detail[5] + if ( + isinstance(countdown_tuple, (tuple, list)) + and len(countdown_tuple) >= 2 + ): + future_ts = float(countdown_tuple[1] or 0.0) + if future_ts > 0: + analyser._current_fudai_future_ts = future_ts + except Exception: + pass + + +def handle_detail_none_in_step4(analyser, start_time: float) -> None: + """步骤 4:detail 为 None 时的早返回处理(写日志 + clear_task_count_flag)。""" + try: + analyser._log_kv("参与", "详情数据为 None,无法执行参与决策") + except Exception: + pass + + clear_task_count_flag(analyser) + + elapsed = time.time() - start_time + analyser._log_kv( + "流程", + "_handle_in_fudai_detail完成(详情为None)", + elapsed_seconds=round(elapsed, 2), + ) + + def try_skip_to_in_fudai_detail_when_verified(analyser, start_time: float) -> bool: """_handle_live_room_has_or_not_fudai 入口:如果已验证过详情页,直接处理详情。