diff --git a/Underlying_Operations.py b/Underlying_Operations.py index b8c98cd..3bc43ef 100644 --- a/Underlying_Operations.py +++ b/Underlying_Operations.py @@ -772,7 +772,8 @@ class underlying_operations: header = f.read(4) if header == b"\x89PNG": validate_out_dur = ( - time_module.time() - validate_out_start + time_module.time() + - validate_out_start ) * 1000.0 if validate_out_dur > 50.0: logging.info( diff --git a/douyin/core/douyin_fudai.py b/douyin/core/douyin_fudai.py index 1e23036..47525f5 100644 --- a/douyin/core/douyin_fudai.py +++ b/douyin/core/douyin_fudai.py @@ -1358,19 +1358,18 @@ class fudai_analyse: ) if preempted: - # 已触发预约回退,设置标志:下一轮直接参与,跳过详情识别 + # 已触发预约回退:为避免“回退后反复检查状态但不参与”的卡死场景,禁用直接参与标志 + try: + self._reservation_back_direct_attend = False + self._force_attend_after_reservation_back = False + self._reservation_back_attempts = 0 + except Exception: + pass try: - self._reservation_back_direct_attend = True - # reset attempts counter when first scheduling direct attend - try: - self._reservation_back_attempts = 0 - except Exception: - pass self._log_kv( "预约", - "[预约] 预约回退成功,设置直接参与标志(跳过详情识别)", - flag_set=True, - next_round_will_check="下一轮将检查此标志并直接参与", + "[预约] 预约回退成功:已禁用直接参与标志,下一轮走正常查找/参与流程", + flag_set=False, ) except Exception: pass diff --git a/douyin/handlers/douyin_swipe_handler.py b/douyin/handlers/douyin_swipe_handler.py index b98b07b..fa00832 100644 --- a/douyin/handlers/douyin_swipe_handler.py +++ b/douyin/handlers/douyin_swipe_handler.py @@ -243,7 +243,12 @@ class SwipeHandler: except Exception: # 回退到 operation.swipe analyser.operation.swipe( - analyser.device_id, start_x, start_y, end_x, end_y, swipe_duration_ms + analyser.device_id, + start_x, + start_y, + end_x, + end_y, + swipe_duration_ms, ) try: analyser._log_kv( # type: ignore[attr-defined] @@ -281,7 +286,9 @@ class SwipeHandler: for i in range(max_back_clicks): try: # 截图并诊断当前阶段 - ok = analyser.operation.get_screenshot(analyser.device_id, use_service=False) + ok = analyser.operation.get_screenshot( + analyser.device_id, use_service=False + ) if not ok: analyser._log_kv( # type: ignore[attr-defined] "超时", f"获取截图失败 ({i+1}/{max_back_clicks})" diff --git a/douyin/reservation/douyin_reservation_logic.py b/douyin/reservation/douyin_reservation_logic.py index 80b071a..58cee61 100644 --- a/douyin/reservation/douyin_reservation_logic.py +++ b/douyin/reservation/douyin_reservation_logic.py @@ -1019,9 +1019,11 @@ def process_reservation_attend_window( analyser._log_kv( "预约", "[预约] process_reservation_attend_window:队列排序完成", - earliest_future_ts=int(float((reservations[0].get("future_ts") or 0.0))) - if reservations - else 0, + earliest_future_ts=( + int(float((reservations[0].get("future_ts") or 0.0))) + if reservations + else 0 + ), ) except Exception: pass diff --git a/douyin/utils/douyin_config.py b/douyin/utils/douyin_config.py index 4bf01fc..de1c8cf 100644 --- a/douyin/utils/douyin_config.py +++ b/douyin/utils/douyin_config.py @@ -16,9 +16,7 @@ class ConfigManager: """配置管理器类""" @staticmethod # type: ignore[misc] - def load_config_from_file( - analyser: Any, config_path: Optional[str] = None - ) -> None: + def load_config_from_file(analyser: Any, config_path: Optional[str] = None) -> None: """从配置文件加载配置并设置到 analyser 对象 参数: @@ -28,9 +26,11 @@ class ConfigManager: if config_path is None: try: import path_config + default_config_path = path_config.get_config_path() except Exception: import path_config + default_config_path = path_config.get_config_path() config_path = getattr(analyser, "config_path", default_config_path) @@ -84,9 +84,7 @@ class ConfigManager: # 高价值福袋配置 if "high_value_fudai_enabled" in config: - analyser.high_value_fudai_enabled = bool( - config["high_value_fudai_enabled"] - ) + analyser.high_value_fudai_enabled = bool(config["high_value_fudai_enabled"]) if "high_value_fudai_threshold_yuan" in config: analyser.high_value_fudai_threshold_yuan = float( @@ -163,7 +161,9 @@ class ConfigManager: analyser.auto_join_fansclub = bool(config["auto_join_fansclub"]) if "fansclub_fail_action" in config: - analyser.fansclub_fail_action = str(config["fansclub_fail_action"] or "stay") + analyser.fansclub_fail_action = str( + config["fansclub_fail_action"] or "stay" + ) if "high_value_fudai_join_ahead_seconds" in config: analyser.high_value_fudai_join_ahead_seconds = int(