Compare commits
2 Commits
35b9d4098d
...
b9e2d86857
| Author | SHA1 | Date | |
|---|---|---|---|
| b9e2d86857 | |||
| fee1f77e87 |
@@ -147,22 +147,23 @@ class ControlUtils(object):
|
||||
print(e)
|
||||
return False
|
||||
|
||||
|
||||
|
||||
|
||||
# 点赞
|
||||
@classmethod
|
||||
def clickLike(cls, session: Client, udid):
|
||||
scale = session.scale
|
||||
x, y = AiUtils.findImageInScreen("add", udid)
|
||||
print(x, y)
|
||||
if x > -1:
|
||||
LogManager.info("点赞了", udid)
|
||||
session.click(x // scale, y // scale + 50)
|
||||
return True
|
||||
else:
|
||||
LogManager.info("没有找到目标", udid)
|
||||
return False
|
||||
try:
|
||||
scale = session.scale
|
||||
x, y = AiUtils.findImageInScreen("add", udid)
|
||||
print(x, y)
|
||||
if x > -1:
|
||||
LogManager.method_info("点赞了", "关注打招呼", udid)
|
||||
session.click(x // scale, y // scale + 50)
|
||||
return True
|
||||
else:
|
||||
LogManager.method_info("没有找到目标", "关注打招呼", udid)
|
||||
return False
|
||||
except Exception as e:
|
||||
LogManager.method_info(f"点赞出现异常,异常的原因:{e}", "关注打招呼", udid)
|
||||
raise False
|
||||
|
||||
# 点击搜索
|
||||
@classmethod
|
||||
|
||||
@@ -203,7 +203,7 @@ class CountryLanguageMapper:
|
||||
"塞尔维亚": "sr",
|
||||
"塞舌尔": "fr",
|
||||
"塞拉利昂": "en",
|
||||
"新加坡": "zh-CN",
|
||||
"新加坡": "en",
|
||||
"荷属圣马丁": "nl",
|
||||
"斯洛伐克": "sk",
|
||||
"斯洛文尼亚": "sl",
|
||||
|
||||
@@ -226,7 +226,6 @@ class ScriptManager():
|
||||
self.comment_flow(filePath, session, udid, recomend_cx, recomend_cy)
|
||||
event.wait(timeout=2)
|
||||
|
||||
|
||||
home = AiUtils.findHomeButton(session)
|
||||
if not home:
|
||||
raise Exception("没有找到首页按钮,重置")
|
||||
@@ -490,7 +489,8 @@ class ScriptManager():
|
||||
state = result.get("state", 0)
|
||||
|
||||
if not state:
|
||||
LogManager.method_info(f"当前主播的状态是:{state} 不通行,取出数据移到列表尾部 继续下一个", "关注打招呼",
|
||||
LogManager.method_info(f"当前主播的状态是:{state} 不通行,取出数据移到列表尾部 继续下一个",
|
||||
"关注打招呼",
|
||||
udid)
|
||||
AiUtils.pop_aclist_first(mode="move")
|
||||
continue
|
||||
@@ -540,7 +540,6 @@ class ScriptManager():
|
||||
LogManager.method_info(f"输入主播id:{aid or '暂无数据'}", "关注打招呼", udid)
|
||||
input.set_text(f"{aid or '暂无数据'}\n")
|
||||
|
||||
|
||||
# 定位 "关注" 按钮 通过关注按钮的位置点击主播首页
|
||||
|
||||
session.appium_settings({"snapshotMaxDepth": 25})
|
||||
@@ -571,12 +570,17 @@ class ScriptManager():
|
||||
|
||||
cellClickResult, workCount = ControlUtils.clickFirstVideoFromDetailPage(session)
|
||||
|
||||
LogManager.method_info(f"是否有视频:{cellClickResult} 作品的数量为:{workCount}", "关注打招呼", udid)
|
||||
|
||||
LogManager.method_info(f"点击第一个视频", "关注打招呼", udid)
|
||||
|
||||
event.wait(timeout=2)
|
||||
|
||||
# 观看主播视频
|
||||
def viewAnchorVideo(workCount):
|
||||
print("开始查看视频,并且重新调整查询深度")
|
||||
LogManager.method_info("开始查看视频,调整节点深度为5", "关注打招呼", udid)
|
||||
|
||||
session.appium_settings({"snapshotMaxDepth": 5})
|
||||
|
||||
if workCount > 3:
|
||||
@@ -611,7 +615,8 @@ class ScriptManager():
|
||||
LogManager.method_info("保存屏幕图像成功", "关注打招呼", udid)
|
||||
event.wait(timeout=2)
|
||||
# 查找add图标
|
||||
r = ControlUtils.clickLike(session, udid)
|
||||
LogManager.method_info("开始点击点赞", "关注打招呼", udid)
|
||||
ControlUtils.clickLike(session, udid)
|
||||
|
||||
count -= 1
|
||||
LogManager.method_info("准备停止脚本", method="task")
|
||||
@@ -623,8 +628,7 @@ class ScriptManager():
|
||||
event.wait(timeout=1)
|
||||
LogManager.method_info("停止脚本成功", method="task")
|
||||
|
||||
|
||||
|
||||
LogManager.method_info(f"是否进行评论:{isComment}", "关注打招呼", udid)
|
||||
# 使用OCR进行评论
|
||||
if isComment:
|
||||
self.comment_flow(filePath, session, udid, 100, 100)
|
||||
@@ -632,6 +636,8 @@ class ScriptManager():
|
||||
|
||||
session.appium_settings({"snapshotMaxDepth": 12})
|
||||
|
||||
LogManager.method_info(f"检查当前是否为视频页面", "关注打招呼", udid)
|
||||
|
||||
is_back_enabled = ControlUtils.isClickBackEnabled(session)
|
||||
if not is_back_enabled:
|
||||
print("返回失败")
|
||||
@@ -675,8 +681,6 @@ class ScriptManager():
|
||||
msgButton = AiUtils.getSendMesageButton(session)
|
||||
event.wait(timeout=2)
|
||||
|
||||
|
||||
|
||||
if msgButton.exists:
|
||||
# 进入聊天页面
|
||||
msgButton.click()
|
||||
@@ -1629,7 +1633,6 @@ class ScriptManager():
|
||||
user_text = None
|
||||
info_count += 1
|
||||
|
||||
|
||||
if user_text:
|
||||
print("点击进入用户主页")
|
||||
user_text.tap()
|
||||
@@ -1900,7 +1903,6 @@ class ScriptManager():
|
||||
LogManager.method_error(f"检测不到收件箱", "检测消息", udid)
|
||||
raise Exception("当前页面找不到收件箱,重启")
|
||||
|
||||
|
||||
# 放在 ScriptManager 类外面或 utils 里
|
||||
def interruptible_sleep(self, event: threading.Event, seconds: float, slice_: float = 1.0):
|
||||
"""把一次长 sleep 拆成 1 秒一片,随时响应 event"""
|
||||
@@ -1942,6 +1944,8 @@ class ScriptManager():
|
||||
LogManager.method_info("开始进行切换账号", "切换账号", udid)
|
||||
LogManager.method_info("重启进行切换账号", "切换账号", udid)
|
||||
|
||||
#
|
||||
|
||||
# 打开个人主页
|
||||
session.appium_settings({"snapshotMaxDepth": 15})
|
||||
user_home = session.xpath('//XCUIElementTypeButton[@name="a11y_vo_profile" or @label="主页"]')
|
||||
@@ -2060,6 +2064,7 @@ class ScriptManager():
|
||||
"切换账号",
|
||||
udid
|
||||
)
|
||||
print(f"本次切换到账号: {target_account} (use={next_idx}, next={(next_idx + 1) % n})", "切换账号", udid)
|
||||
|
||||
# 在同一份 OCR 结果里定位该用户名的坐标并点击
|
||||
result = TencentOCR.find_last_name_bbox(ocr_json, target_account)
|
||||
@@ -2072,7 +2077,7 @@ class ScriptManager():
|
||||
center_y = result["center"]["y"]
|
||||
|
||||
# 随机偏移(增强拟人)
|
||||
num = random.randint(-60, 60)
|
||||
num = random.randint(-10, 10)
|
||||
# 分辨率/坐标映射(按你设备比例;你原来是 /3)
|
||||
tap_x = int((center_x + num) / 3)
|
||||
tap_y = int((center_y + num) / 3)
|
||||
|
||||
Reference in New Issue
Block a user