diff --git a/.idea/workspace.xml b/.idea/workspace.xml index f0860bd..9df672c 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -6,8 +6,10 @@ - - + + + + - { + "keyToString": { + "Python.123.executor": "Run", + "Python.Main.executor": "Run", + "RunOnceActivity.ShowReadmeOnStart": "true", + "SHARE_PROJECT_CONFIGURATION_FILES": "true", + "git-widget-placeholder": "main", + "javascript.nodejs.core.library.configured.version": "20.17.0", + "javascript.nodejs.core.library.typings.version": "20.17.58", + "last_opened_file_path": "F:/company code/AI item/20250820/iOSAI", + "node.js.detected.package.eslint": "true", + "node.js.detected.package.tslint": "true", + "node.js.selected.package.eslint": "(autodetect)", + "node.js.selected.package.tslint": "(autodetect)", + "nodejs_package_manager_path": "npm", + "settings.editor.selected.configurable": "com.gitee.ui.GiteeSettingsConfigurable", + "vue.rearranger.settings.migration": "true" } -}]]> +} @@ -163,7 +165,8 @@ - + + - @@ -187,7 +198,7 @@ - - + + \ No newline at end of file diff --git a/Utils/ControlUtils.py b/Utils/ControlUtils.py index df64ad4..af037f5 100644 --- a/Utils/ControlUtils.py +++ b/Utils/ControlUtils.py @@ -81,11 +81,11 @@ class ControlUtils(object): x, y = AiUtils.findImageInScreen("add", udid) print(x, y) if x > -1: - print("点赞了") + LogManager.info("点赞了",udid) session.click(x // scale, y // scale + 50) return True else: - print("没有找到目标") + LogManager.info("没有找到目标",udid) return False # 点击搜索 diff --git a/resources/03cb0d61638ab919e9c9c5e016b969ff40925b0c/bgv.png b/resources/03cb0d61638ab919e9c9c5e016b969ff40925b0c/bgv.png deleted file mode 100644 index 48631f4..0000000 Binary files a/resources/03cb0d61638ab919e9c9c5e016b969ff40925b0c/bgv.png and /dev/null differ diff --git a/resources/833c034d29ee6b79e1dfd88dc1d454f3da1e8a3d/bgv.png b/resources/833c034d29ee6b79e1dfd88dc1d454f3da1e8a3d/bgv.png deleted file mode 100644 index 31adfbf..0000000 Binary files a/resources/833c034d29ee6b79e1dfd88dc1d454f3da1e8a3d/bgv.png and /dev/null differ diff --git a/script/ScriptManager.py b/script/ScriptManager.py index 42bb3a3..6e16251 100644 --- a/script/ScriptManager.py +++ b/script/ScriptManager.py @@ -49,7 +49,7 @@ class ScriptManager(): time.sleep(1) ControlUtils.openTikTok(session, udid) time.sleep(3) - + LogManager.info("养号重启tiktok") AiUtils.makeUdidDir(udid) # ========= 主循环 ========= @@ -59,7 +59,15 @@ class ScriptManager(): session.appium_settings({"snapshotMaxDepth": 15}) # 判断当前页面上是否有推荐按钮 - el = session(xpath='//XCUIElementTypeButton[@name="top_tabs_recomend"]') + # el = session(xpath='//XCUIElementTypeButton[@name="top_tabs_recomend"]') + # node = session.xpath( + # '//XCUIElementTypeButton[@name="top_tabs_recomend" or @name="推荐" or @label="推荐"]' + # ) + + el = session.xpath( + '//XCUIElementTypeButton[@name="top_tabs_recomend" or @name="推荐" or @label="推荐"]' + ) + if not el.exists: # 记录日志 LogManager.error("找不到推荐按钮,养号出现问题,重启养号功能", udid=udid) @@ -70,6 +78,7 @@ class ScriptManager(): LogManager.error("当前页面不是推荐页面,养号出现问题,重启养号功能", udid=udid) raise Exception("当前页面不是推荐页面,养号出现问题,重启养号功能") + LogManager.info("当前页面是推荐页面,开始养号") # 重新设置节点的深度,防止手机进行卡顿 session.appium_settings({"snapshotMaxDepth": 0}) @@ -105,7 +114,7 @@ class ScriptManager(): needLike = random.randint(0, 100) homeButton = AiUtils.findHomeButton(udid) if homeButton: - print("有首页按钮,查看视频") + LogManager.info("有首页按钮,查看视频", udid) videoTime = random.randint(5, 15) time.sleep(videoTime) @@ -115,16 +124,16 @@ class ScriptManager(): session.appium_settings({"snapshotMaxDepth": 0}) if needLike < 3: - print("点赞") + LogManager.info("进行点赞", udid) ControlUtils.clickLike(session, udid) - print("继续观看视频") + LogManager.info("继续观看视频", udid) videoTime = random.randint(10, 30) time.sleep(videoTime) - print("准备划到下一个视频") + LogManager.info("准备划到下一个视频", udid) client.swipe_up() else: - print("找不到首页按钮。出错了") + LogManager.error("找不到首页按钮。出错了", udid) else: nextTime = random.randint(1, 5) time.sleep(nextTime) @@ -135,8 +144,7 @@ class ScriptManager(): raise e # 抛出给上层,触发重生机制 except Exception as e: - LogManager.error(f"养号出现异常: {e}", udid) - print(f"[{udid}] 养号出现异常,将重启流程: {e}") + LogManager.error(f"[{udid}] 养号出现异常,将重启流程: {e}", udid) retries += 1 time.sleep(3) # 等待后重生 @@ -171,6 +179,14 @@ class ScriptManager(): raise Exception(f"找不到直播按钮,抛出异常 重新启动") time.sleep(20) + live_button = session(xpath='//XCUIElementTypeButton[@name="直播"]') + if live_button.exists: + continue + + + # 下滑一下 + client.swipe_up() + # 3) 取分辨率;可选重建 session 规避句柄陈旧 size = session.window_size() width, height = size.width, size.height @@ -182,10 +198,15 @@ class ScriptManager(): # 找到一个看直播的时候肯定有的元素,当这个元素没有的时候,就代表当前的页面出现了问题 # 需要抛出异常,重启这个流程 + el1 = session.xpath('//XCUIElementTypeOther[@name="GBLFeedRootViewComponent"]') + el2 = session.xpath('//XCUIElementTypeOther[@value="0%"]') - if not session(xpath="//XCUIElementTypeOther[@name='RoomContainer' and @visible='true']").exists: + if not (el1.exists or el2.exists): + print("当前页面不是直播间,重启刷直播") LogManager.error("当前页面不是直播间,重启刷直播", udid=udid) raise Exception("当前页面不是直播间") + else: + print("当前页面是直播间,继续刷直播") # PK 直接划走 if session(xpath='//XCUIElementTypeOther[@name="kGBLInteractionViewMatchScoreBar"]').exists: @@ -205,7 +226,7 @@ class ScriptManager(): print("✅ 单窗口,(10%概率)开始点赞") # 随机点赞(仍保留中途保护) - if random.random() >= 0.90: + if random.random() >= 0.97: print("开始点赞") for _ in range(random.randint(10, 30)): # 中途转PK/连麦立即跳过