From 4d805474db50e78826bfb301b988306cc26c339a Mon Sep 17 00:00:00 2001 From: Your Name Date: Tue, 13 Jan 2026 01:05:56 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E5=85=BB=E5=8F=B7?= =?UTF-8?q?=E6=A8=A1=E5=BC=8F=E4=B8=8B=E7=9A=84=E6=A1=8C=E9=9D=A2=E6=A3=80?= =?UTF-8?q?=E6=B5=8B=E5=92=8C=E8=87=AA=E6=95=91=E6=81=A2=E5=A4=8D=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- douyin/other/douyin_yanghao.py | 51 ++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/douyin/other/douyin_yanghao.py b/douyin/other/douyin_yanghao.py index 03be9c4..98285b9 100644 --- a/douyin/other/douyin_yanghao.py +++ b/douyin/other/douyin_yanghao.py @@ -426,6 +426,57 @@ def yanghao_idle(analyser, total_seconds: int) -> None: except Exception: analyser.operation.delay(1) + def _yanghao_check_and_recover_from_desktop(analyser) -> bool: + """养号模式下的桌面检测和自救恢复""" + try: + # 获取前台包名 + top_pkg = analyser.operation.get_top_package(analyser.device_id) or "" + + # 检查是否在抖音前台 + is_douyin_pkg = top_pkg and ( + "aweme" in top_pkg + or "douyin" in top_pkg + or "com.ss.android.ugc" in top_pkg + ) + + if top_pkg and not is_douyin_pkg: + print(f"[养号] 自救: 检测到不在抖音前台,前台包名={top_pkg}") + + # 执行自救操作 + try: + # 点击桌面图标 + desktop_x = int(getattr(analyser, "desktop_icon_x", 153) or 153) + desktop_y = int(getattr(analyser, "desktop_icon_y", 260) or 260) + analyser.operation.click(analyser.device_id, desktop_x, desktop_y) + analyser.operation.delay(2) + + # 点击直播按钮(备用坐标) + fallback_x = int(getattr(analyser, "yanghao_fallback_live_x", 540) or 540) + fallback_y = int(getattr(analyser, "yanghao_fallback_live_y", 2000) or 2000) + analyser.operation.click(analyser.device_id, fallback_x, fallback_y) + analyser.operation.delay(1.5) + + # 点击进入直播间(备用坐标) + enter_x = int(getattr(analyser, "yanghao_fallback_enter_live_x", 540) or 540) + enter_y = int(getattr(analyser, "yanghao_fallback_enter_live_y", 1200) or 1200) + analyser.operation.click(analyser.device_id, enter_x, enter_y) + analyser.operation.delay(0.6) + analyser.operation.click(analyser.device_id, enter_x, enter_y) + analyser.operation.delay(2.0) + + print("[养号] 自救: 恢复操作完成") + return True + + except Exception as e: + print(f"[养号] 自救: 恢复操作失败: {e}") + return False + else: + return False + + except Exception as e: + print(f"[养号] 自救: 桌面检测异常: {e}") + return False + def _detect_icon( action: str, base_x: int,