From 5bf07f60c6ff6acd04f723d537f9c221c2cb3e04 Mon Sep 17 00:00:00 2001 From: Your Name Date: Sat, 17 Jan 2026 21:10:48 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E6=BB=91=E5=8A=A8?= =?UTF-8?q?=E5=88=87=E6=8D=A2=E9=80=BB=E8=BE=91=EF=BC=8C=E5=A2=9E=E5=BC=BA?= =?UTF-8?q?=E7=A6=8F=E8=A2=8B=E4=BF=A1=E6=81=AF=E5=A4=84=E7=90=86=E5=92=8C?= =?UTF-8?q?=E6=8E=A8=E8=8D=90=E9=A1=B5=E8=BF=94=E5=9B=9E=E6=B5=81=E7=A8=8B?= =?UTF-8?q?=E7=9A=84=E5=8F=AF=E9=9D=A0=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- douyin/handlers/douyin_swipe_handler.py | 46 +++++++++++++------------ 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/douyin/handlers/douyin_swipe_handler.py b/douyin/handlers/douyin_swipe_handler.py index c4c0321..57a373c 100644 --- a/douyin/handlers/douyin_swipe_handler.py +++ b/douyin/handlers/douyin_swipe_handler.py @@ -104,6 +104,16 @@ class SwipeHandler: ) except Exception: pass + # 如果当前位置已含有福袋信息,跳过立即上滑切换,让后续流程继续执行 + try: + analyser._log_kv( # type: ignore[attr-defined] + "预约", + "[预约] 已跳过重复记录,暂停上滑切换以完成后续流程", + room_pos=room_pos, + ) + except Exception: + pass + return except Exception: pass @@ -300,30 +310,22 @@ class SwipeHandler: except Exception: analyser.operation.delay(0.8) - # 尝试确认是否已回到推荐页;若不在推荐页,则兜底走原来的“多次返回到推荐页”逻辑 + # 为了提高可靠性:统一使用多次返回键直至到达推荐页的逻辑(比单次判断更稳健) try: - ok = analyser.operation.get_screenshot( - analyser.device_id, use_service=False - ) - if ok: - stage, seen = analyser._diagnose_stage_from_current_screen() # type: ignore[attr-defined] - if stage != "RECOMMEND_PAGE": - try: - analyser._log_kv( # type: ignore[attr-defined] - "流程", - "返回键回退后未到推荐页,兜底返回推荐页并重进直播", - stage=stage, - seen=seen, - ) - except Exception: - pass - SwipeHandler.return_to_recommend_and_reenter_live(analyser) - else: - SwipeHandler._reenter_live_from_recommend(analyser) - else: - SwipeHandler.return_to_recommend_and_reenter_live(analyser) - except Exception: + # 尝试先短延迟等待界面变化,再调用完整返回流程以确保到达推荐页 + try: + analyser.operation.delay( + getattr(analyser, "RETURN_STEP_DELAY_SECONDS", 0.8) + ) + except Exception: + time.sleep(0.8) SwipeHandler.return_to_recommend_and_reenter_live(analyser) + except Exception: + # 如果完整流程也失败,仍然兜底尝试重新进入 + try: + SwipeHandler._reenter_live_from_recommend(analyser) + except Exception: + pass else: try: rx = int(getattr(analyser, "resolution_ratio_x", 1080) or 1080)