From d35fadde549741291ec3e4fcfde277104101c785 Mon Sep 17 00:00:00 2001 From: Codex Date: Fri, 22 May 2026 11:49:39 +0800 Subject: [PATCH] =?UTF-8?q?refactor(fudai):=20=E5=A4=8D=E7=94=A8=20fallbac?= =?UTF-8?q?k=5Fswipe=5Fup=5Fto=5Fnext=5Flive=20helper=20=E6=9B=BF=E6=8D=A2?= =?UTF-8?q?"task=5Fcount=5Fzero=20=E8=BF=9E=E7=BB=AD=E5=A4=B1=E8=B4=A5"?= =?UTF-8?q?=E5=88=86=E6=94=AF=E9=87=8D=E5=A4=8D=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit _handle_in_fudai_detail 中"连续3次任务数量为0"分支也有 65 行结构完全相同的 兜底 ADB 上滑逻辑(与上一 commit 抽出的 fallback_swipe_up_to_next_live 完全一致), 复用同一个 helper。 douyin_fudai.py: 2336 → 2281 行 (-55) 验证: - pytest 1013 passed - compile OK Co-Authored-By: Claude Opus 4.7 (1M context) --- douyin/core/douyin_fudai.py | 65 +++---------------------------------- 1 file changed, 5 insertions(+), 60 deletions(-) diff --git a/douyin/core/douyin_fudai.py b/douyin/core/douyin_fudai.py index 6e5c3fb..539ca5e 100644 --- a/douyin/core/douyin_fudai.py +++ b/douyin/core/douyin_fudai.py @@ -1771,66 +1771,11 @@ class fudai_analyse: needswitch = True if needswitch: try: - if hasattr(self, "swipe_up_to_next_live"): - self.swipe_up_to_next_live() - else: - rx = int( - getattr(self, "resolution_ratio_x", 1080) - or 1080 - ) - ry = int( - getattr(self, "resolution_ratio_y", 2400) - or 2400 - ) - start_x = 540 * rx // 1080 - start_y = 1200 * ry // 2400 - end_x = 540 * rx // 1080 - end_y = 600 * ry // 2400 - # 直接使用 ADB 内部滑动命令 - try: - if hasattr(self.operation, "_adb_path"): - adb_cmd = self.operation._adb_path() - else: - adb_cmd = ( - os.environ.get( - "ADB_EXECUTABLE", "adb" - ) - or "adb" - ) - if adb_cmd.startswith( - '"' - ) and adb_cmd.endswith('"'): - adb_cmd = adb_cmd[1:-1] - cmd = [ - adb_cmd, - "-s", - str(self.device_id), - "shell", - "input", - "swipe", - str(int(start_x)), - str(int(start_y)), - str(int(end_x)), - str(int(end_y)), - "300", - ] - subprocess.run( - cmd, - timeout=5.0, - stdout=subprocess.PIPE, - stderr=subprocess.PIPE, - check=False, - ) - except Exception: - # 回退到 operation.swipe - self.operation.swipe( - self.device_id, - start_x, - start_y, - end_x, - end_y, - 300, - ) + from douyin.core.fudai_modules.fudai_detail_helpers import ( + fallback_swipe_up_to_next_live, + ) + + fallback_swipe_up_to_next_live(self) self.operation.delay(0.5) except Exception: pass