diff --git a/douyin/core/douyin_fudai.py b/douyin/core/douyin_fudai.py index e891120..a8fb3e0 100644 --- a/douyin/core/douyin_fudai.py +++ b/douyin/core/douyin_fudai.py @@ -926,29 +926,11 @@ class fudai_analyse: # 抢占逻辑已删除,直接继续处理 else: # 单间模式:不需要回退,预约会在当前直播间自动识别和参与 - # 只需要清理过期的预约 - try: - self._log_kv( - "预约", - "[预约] 单间模式(needswitch=False):不执行预约回退,预约会在当前直播间自动识别和参与", - reservations_count=( - len(self.reservations) if self.reservations else 0 - ), - ) + from douyin.core.fudai_modules.fudai_detail_helpers import ( + cleanup_expired_reservations_single_room, + ) - # use module-level `douyin_reservation_logic` - douyin_reservation_logic.cleanup_expired_reservations( - self, self.reservations, _write_state - ) - except Exception as exc: - try: - self._log_kv( - "预约", - "[预约] 单间模式下清理过期预约时出错", - error=str(exc), - ) - except Exception: - pass + cleanup_expired_reservations_single_room(self, _write_state) except Exception: pass diff --git a/douyin/core/fudai_modules/fudai_detail_helpers.py b/douyin/core/fudai_modules/fudai_detail_helpers.py index b9b666c..17d13ab 100644 --- a/douyin/core/fudai_modules/fudai_detail_helpers.py +++ b/douyin/core/fudai_modules/fudai_detail_helpers.py @@ -42,6 +42,37 @@ def log_screenshot_failed( pass +def cleanup_expired_reservations_single_room(analyser, write_state_callback) -> None: + """run_once_basic 单间模式(needswitch=False)下清理过期预约。 + + 单间模式不切换直播间,预约会在当前直播间自动识别和参与,因此只需要 + 调用 douyin_reservation_logic.cleanup_expired_reservations 清理过期项。 + """ + from douyin.reservation import reservation_logic as douyin_reservation_logic + + try: + analyser._log_kv( + "预约", + "[预约] 单间模式(needswitch=False):不执行预约回退,预约会在当前直播间自动识别和参与", + reservations_count=( + len(analyser.reservations) if analyser.reservations else 0 + ), + ) + + douyin_reservation_logic.cleanup_expired_reservations( + analyser, analyser.reservations, write_state_callback + ) + except Exception as exc: + try: + analyser._log_kv( + "预约", + "[预约] 单间模式下清理过期预约时出错", + error=str(exc), + ) + except Exception: + pass + + def reset_to_first_room_after_all_reservations_done( analyser, swipe_down_back_callback ) -> bool: