diff --git a/douyin/core/douyin_fudai.py b/douyin/core/douyin_fudai.py index e31adec..446d5a9 100644 --- a/douyin/core/douyin_fudai.py +++ b/douyin/core/douyin_fudai.py @@ -1761,32 +1761,11 @@ class fudai_analyse: douyin_live_room.reflash_zhibo(self) elif stage == "FUDai_RESULT": # 抽奖结果弹窗:处理开奖结果(使用OCR识别,不使用阶段诊断) - # 清除等待开奖标志 - self._waiting_for_lottery_result = False - self._current_attending_reservation_fudai = False - - self._log_kv("开奖结果", "检测到抽奖结果弹窗,使用OCR识别处理") - # 直接OCR识别并处理 - lottery_ocr_start = time.time() - result = self._check_lottery_result_by_ocr() - if result: - self._handle_lottery_result_by_ocr(result) - else: - # OCR识别失败,使用返回键关闭 - try: - self.operation.click_back(self.device_id) - self.operation.delay(0.5) - self.swipe_up_to_next_live() - except Exception: - pass - lottery_ocr_elapsed = time.time() - lottery_ocr_start - self._log_kv("开奖结果", f"OCR处理完成,耗时: {lottery_ocr_elapsed:.3f}s") - elapsed = time.time() - start_time - self._log_kv( - "流程", - "run_once_basic完成(处理开奖结果)", - elapsed_seconds=round(elapsed, 2), + from douyin.core.fudai_modules.fudai_detail_helpers import ( + handle_lottery_result_stage, ) + + handle_lottery_result_stage(self, start_time) return elif stage in ("LIVE_CLOSED",): # 直播结束:下滑/切下一个 diff --git a/douyin/core/fudai_modules/fudai_detail_helpers.py b/douyin/core/fudai_modules/fudai_detail_helpers.py index 6d3d899..b66cebb 100644 --- a/douyin/core/fudai_modules/fudai_detail_helpers.py +++ b/douyin/core/fudai_modules/fudai_detail_helpers.py @@ -42,6 +42,43 @@ def log_screenshot_failed( pass +def handle_lottery_result_stage(analyser, start_time: float) -> None: + """run_once_basic stage == "FUDai_RESULT" 分支: + + - 清除等待开奖标志 + - OCR 识别开奖结果文本 + - 命中则交给 _handle_lottery_result_by_ocr 处理;未命中则按返回键 + 切换下一个直播间 + - 写完成日志 + + 调用方应在调用后立即 return。 + """ + # 清除等待开奖标志 + analyser._waiting_for_lottery_result = False + analyser._current_attending_reservation_fudai = False + + analyser._log_kv("开奖结果", "检测到抽奖结果弹窗,使用OCR识别处理") + lottery_ocr_start = time.time() + result = analyser._check_lottery_result_by_ocr() + if result: + analyser._handle_lottery_result_by_ocr(result) + else: + # OCR识别失败,使用返回键关闭 + try: + analyser.operation.click_back(analyser.device_id) + analyser.operation.delay(0.5) + analyser.swipe_up_to_next_live() + except Exception: + pass + lottery_ocr_elapsed = time.time() - lottery_ocr_start + analyser._log_kv("开奖结果", f"OCR处理完成,耗时: {lottery_ocr_elapsed:.3f}s") + elapsed = time.time() - start_time + analyser._log_kv( + "流程", + "run_once_basic完成(处理开奖结果)", + elapsed_seconds=round(elapsed, 2), + ) + + def handle_recommend_page(analyser) -> None: """run_once_basic stage == "RECOMMEND_PAGE" 分支: