调整项目结构。修改工具类逻辑
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
import random
|
||||
import time
|
||||
import wda
|
||||
|
||||
import os
|
||||
from Utils.AiUtils import AiUtils
|
||||
from Utils.ControlUtils import ControlUtils
|
||||
from Utils.LogManager import LogManager
|
||||
|
||||
|
||||
# 脚本管理类
|
||||
@@ -33,39 +34,64 @@ class ScriptManager():
|
||||
ControlUtils.openTikTok(session)
|
||||
time.sleep(3)
|
||||
|
||||
# 创建udid名称的目录
|
||||
AiUtils.makeUdidDir(udid)
|
||||
|
||||
# 假设此时有个开关
|
||||
while not event.is_set():
|
||||
try:
|
||||
img = client.screenshot()
|
||||
filePath = "resources/bgv.png"
|
||||
filePath = f"resources/{udid}/bgv.png"
|
||||
img.save(filePath)
|
||||
LogManager.info("保存屏幕图像成功", udid)
|
||||
print("保存了背景图")
|
||||
time.sleep(1)
|
||||
except Exception as e:
|
||||
LogManager.error(e, udid)
|
||||
print(e)
|
||||
|
||||
# 判断视频类型。普通视频、广告、直播,只有普通视频停留。其他视频全部划走
|
||||
addX, addY = AiUtils.findImageInScreen("add")
|
||||
# 如果找到普通视频
|
||||
if addX > 0:
|
||||
needLike = random.randint(0, 10)
|
||||
try:
|
||||
# 判断视频类型
|
||||
addX, addY = AiUtils.findImageInScreen("add", udid)
|
||||
isSame = False
|
||||
for i in range(2):
|
||||
tx, ty = AiUtils.findImageInScreen("add", udid)
|
||||
if addX == tx and addY == ty:
|
||||
isSame = True
|
||||
time.sleep(1)
|
||||
else:
|
||||
isSame = False
|
||||
break
|
||||
|
||||
# 随机时间间隔
|
||||
videoTime = random.randint(2,5)
|
||||
time.sleep(videoTime)
|
||||
# 如果找到普通视频
|
||||
if addX > 0 and isSame:
|
||||
needLike = random.randint(0, 10)
|
||||
# 查找首页按钮
|
||||
homeButton = AiUtils.findHomeButton(udid)
|
||||
if homeButton:
|
||||
print("查看视频")
|
||||
videoTime = random.randint(5, 15)
|
||||
time.sleep(videoTime)
|
||||
|
||||
# 百分之三的概率点赞
|
||||
if needLike < 3:
|
||||
ControlUtils.clickLike(session)
|
||||
# 百分之三的概率点赞
|
||||
if needLike < 3:
|
||||
print("点赞")
|
||||
ControlUtils.clickLike(session, udid)
|
||||
|
||||
# 随机时间间隔
|
||||
# videoTime = random.randint(10,30)
|
||||
# time.sleep(videoTime)
|
||||
session.swipe_up()
|
||||
else:
|
||||
# 随机时间
|
||||
nextTime = random.randint(1,5)
|
||||
time.sleep(nextTime)
|
||||
session.swipe_up()
|
||||
continue
|
||||
print("继续观看视频")
|
||||
videoTime = random.randint(10, 30)
|
||||
time.sleep(videoTime)
|
||||
print("准备划到下一个视频")
|
||||
client.swipe_up()
|
||||
else:
|
||||
print("目前没有首页按钮。需要另外处理")
|
||||
else:
|
||||
nextTime = random.randint(1, 5)
|
||||
time.sleep(nextTime)
|
||||
client.swipe_up()
|
||||
except Exception as e:
|
||||
print(f"发生异常:{e}")
|
||||
client.swipe_up()
|
||||
|
||||
# manager = ScriptManager()
|
||||
# manager.growAccount("eca000fcb6f55d7ed9b4c524055214c26a7de7aa")
|
||||
|
||||
Reference in New Issue
Block a user