diff --git a/douyin/core/douyin_fudai.py b/douyin/core/douyin_fudai.py index b0d08c6..6983070 100644 --- a/douyin/core/douyin_fudai.py +++ b/douyin/core/douyin_fudai.py @@ -1244,28 +1244,11 @@ class fudai_analyse: detail = getattr(self, "_last_fudai_detail_tuple", None) if detail is None or not isinstance(detail, tuple) or len(detail) < 6: # 如果没有保存的详情数据,需要重新读取(兜底逻辑) - try: - self._log_kv( - "流程", - "_handle_in_fudai_detail:未找到第一次读取的详情数据,重新读取", - ) - except Exception: - pass - detail = douyin_fudai_detail.read_fudai_detail_with_retries( - self, - fudai_x=0, - read_once_callback=douyin_fudai_detail.read_fudai_detail_once, - close_detail_callback=douyin_fudai_detail.close_fudai_detail, - ensure_open_callback=douyin_fudai_detail.ensure_fudai_detail_open, + from douyin.core.fudai_modules.fudai_detail_helpers import ( + reread_fudai_detail_fallback, ) - # 重新读取后,更新保存的详情数据 - if detail and isinstance(detail, tuple) and len(detail) >= 6: - self._last_fudai_detail_tuple = detail - # 设置当前福袋的 content(使用 cast 帮助静态分析) - detail_t: Tuple[Any, ...] = tuple(detail) - self._current_fudai_content = ( - detail_t[0] if len(detail_t) > 0 else "" - ) + + detail = reread_fudai_detail_fallback(self) else: # 使用第一次保存的详情数据:直接参与(不进行验证) from douyin.core.fudai_modules.fudai_detail_helpers import ( diff --git a/douyin/core/fudai_modules/fudai_detail_helpers.py b/douyin/core/fudai_modules/fudai_detail_helpers.py index f16a50d..1f9fc53 100644 --- a/douyin/core/fudai_modules/fudai_detail_helpers.py +++ b/douyin/core/fudai_modules/fudai_detail_helpers.py @@ -42,6 +42,42 @@ def log_screenshot_failed( pass +def reread_fudai_detail_fallback(analyser): + """_handle_in_fudai_detail 步骤1:未找到保存的详情数据时的兜底重读逻辑。 + + 流程: + - 写日志说明 + - 调用 read_fudai_detail_with_retries 重新读取 + - 成功则更新 _last_fudai_detail_tuple 和 _current_fudai_content + + 返回: + 重新读取的 detail(成功)或 None(失败) + """ + from douyin.fudai import douyin_fudai_detail + + try: + analyser._log_kv( + "流程", + "_handle_in_fudai_detail:未找到第一次读取的详情数据,重新读取", + ) + except Exception: + pass + + detail = douyin_fudai_detail.read_fudai_detail_with_retries( + analyser, + fudai_x=0, + read_once_callback=douyin_fudai_detail.read_fudai_detail_once, + close_detail_callback=douyin_fudai_detail.close_fudai_detail, + ensure_open_callback=douyin_fudai_detail.ensure_fudai_detail_open, + ) + + if detail and isinstance(detail, tuple) and len(detail) >= 6: + analyser._last_fudai_detail_tuple = detail + analyser._current_fudai_content = detail[0] if len(detail) > 0 else "" + + return detail + + def handle_second_open_direct_attend( analyser, start_time: float, step1_start: float ) -> bool: