diff --git a/douyin/core/douyin_fudai.py b/douyin/core/douyin_fudai.py index 1937435..441e253 100644 --- a/douyin/core/douyin_fudai.py +++ b/douyin/core/douyin_fudai.py @@ -888,46 +888,11 @@ class fudai_analyse: needswitch_cfg = True # 添加详细的调试日志,确认 needswitch 的值和预约信息 - try: - # 输出第一个预约的详细信息 - first_reservation_info = {} - if self.reservations and len(self.reservations) > 0: - first_r = self.reservations[0] - try: - ft = float(first_r.get("future_ts") or 0) - from datetime import datetime + from douyin.core.fudai_modules.fudai_detail_helpers import ( + log_first_reservation_check, + ) - now_ts = time.time() - ft_str = ( - datetime.fromtimestamp(ft).strftime("%Y-%m-%d %H:%M:%S") - if ft > 0 - else "无效" - ) - remain_seconds = int(ft - now_ts) if ft > 0 else 0 - first_reservation_info = { - "future_ts": int(ft) if ft > 0 else 0, - "future_str": ft_str, - "value": float(first_r.get("prize_value_yuan", 0)), - "pos_seen": int(first_r.get("pos_seen", 0)), - "remain_seconds": remain_seconds, - "current_room_pos": int( - getattr(self, "room_pos", 0) or 0 - ), - } - except Exception: - pass - - self._log_kv( - "预约", - "[预约] run_once_basic:检查预约回退条件", - needswitch_cfg=needswitch_cfg, - reservations_count=( - len(self.reservations) if self.reservations else 0 - ), - first_reservation=first_reservation_info, - ) - except Exception: - pass + log_first_reservation_check(self, needswitch_cfg) if needswitch_cfg: # 多间模式:需要回退到预约直播间 diff --git a/douyin/core/fudai_modules/fudai_detail_helpers.py b/douyin/core/fudai_modules/fudai_detail_helpers.py index d659bc6..483019b 100644 --- a/douyin/core/fudai_modules/fudai_detail_helpers.py +++ b/douyin/core/fudai_modules/fudai_detail_helpers.py @@ -42,6 +42,51 @@ def log_screenshot_failed( pass +def log_first_reservation_check(analyser, needswitch_cfg: bool) -> None: + """run_once_basic 步骤 0.1.3:记录第一个预约的检查日志(纯日志,无副作用)。 + + 输出当前 needswitch 配置 + 队列长度 + 第一个预约的详细信息(future_ts、 + 剩余秒数、目标位置等)。 + """ + try: + from datetime import datetime + + first_reservation_info = {} + if analyser.reservations and len(analyser.reservations) > 0: + first_r = analyser.reservations[0] + try: + ft = float(first_r.get("future_ts") or 0) + now_ts = time.time() + ft_str = ( + datetime.fromtimestamp(ft).strftime("%Y-%m-%d %H:%M:%S") + if ft > 0 + else "无效" + ) + remain_seconds = int(ft - now_ts) if ft > 0 else 0 + first_reservation_info = { + "future_ts": int(ft) if ft > 0 else 0, + "future_str": ft_str, + "value": float(first_r.get("prize_value_yuan", 0)), + "pos_seen": int(first_r.get("pos_seen", 0)), + "remain_seconds": remain_seconds, + "current_room_pos": int(getattr(analyser, "room_pos", 0) or 0), + } + except Exception: + pass + + analyser._log_kv( + "预约", + "[预约] run_once_basic:检查预约回退条件", + needswitch_cfg=needswitch_cfg, + reservations_count=( + len(analyser.reservations) if analyser.reservations else 0 + ), + first_reservation=first_reservation_info, + ) + except Exception: + pass + + def log_reservation_check_status(analyser, high_value_enabled: bool) -> None: """run_once_basic 步骤 0.1.2:记录预约回退的触发条件日志(纯日志,无副作用)。