'commit'
This commit is contained in:
@@ -73,9 +73,25 @@ async def get_station_list(d, service, max_scrolls=MAX_SCROLLS):
|
||||
logger.info("检查是否存在广告弹窗...")
|
||||
ad_res = await ReadImageKit.detect_ad_popup(screenshot_path, device_info=device_info)
|
||||
if ad_res:
|
||||
logger.info(f"检测到广告弹窗,准备关闭: {ad_res}")
|
||||
d.click(ad_res['x'], ad_res['y'])
|
||||
await asyncio.sleep(1.5)
|
||||
ad_type = ad_res.get("ad_type")
|
||||
logger.info(f"检测到广告弹窗,准备关闭: {ad_res} [Type: {ad_type}]")
|
||||
|
||||
x, y = ad_res['x'], ad_res['y']
|
||||
|
||||
if ad_type == "rabbit":
|
||||
logger.info(">>> 检测到顽固的兔子广告,执行强力双击策略...")
|
||||
# 使用 u2 的 double_click,它比两次 click + sleep 更快
|
||||
d.double_click(x, y, duration=0.05)
|
||||
|
||||
# 处理“误触背景卡片”的逻辑
|
||||
logger.info(">>> 考虑到可能误触背景卡片,等待 2s 后执行返回操作...")
|
||||
await asyncio.sleep(2.0)
|
||||
d.press("back")
|
||||
await asyncio.sleep(1.0)
|
||||
logger.info(">>> 已尝试从误触页面返回。")
|
||||
else:
|
||||
d.click(x, y)
|
||||
await asyncio.sleep(1.5)
|
||||
# 重新截图
|
||||
if os.path.exists(screenshot_path): os.remove(screenshot_path)
|
||||
screenshot_path = take_screenshot(d, image_uuid, save_dir=TEMP_IMAGE_DIR)
|
||||
|
||||
@@ -133,9 +133,14 @@ class ReadImageKit:
|
||||
if result.get("has_ad") and result.get("close_point"):
|
||||
if result.get("ad_type") == "rabbit":
|
||||
logger.info("大模型找到了兔子广告!")
|
||||
# 强制使用固定坐标 (94, 830) - 归一化 0-1000
|
||||
# 根据多次 CV 测试结果 (94, 828) 和 (93, 830) 的综合评估
|
||||
logger.info(">>> 采用强制固定坐标策略 (94, 830) 以确保点击准确性")
|
||||
norm_point = [94, 830]
|
||||
else:
|
||||
norm_point = result["close_point"]
|
||||
|
||||
# 转换坐标
|
||||
norm_point = result["close_point"]
|
||||
if len(norm_point) == 2:
|
||||
if not device_info:
|
||||
device_info = cls._FALLBACK_DEVICE_INFO
|
||||
@@ -147,7 +152,11 @@ class ReadImageKit:
|
||||
x = int(norm_point[0] / 1000 * w)
|
||||
y = int(norm_point[1] / 1000 * h)
|
||||
|
||||
return {"x": x, "y": y}
|
||||
return {
|
||||
"x": x,
|
||||
"y": y,
|
||||
"ad_type": result.get("ad_type", "unknown")
|
||||
}
|
||||
|
||||
return None
|
||||
|
||||
|
||||
@@ -168,9 +168,25 @@ async def get_station_list(d, service, uploader, max_scrolls=MAX_SCROLLS):
|
||||
logger.info("检查是否存在广告弹窗...")
|
||||
ad_res = await ReadImageKit.detect_ad_popup(screenshot_path, device_info=device_info)
|
||||
if ad_res:
|
||||
logger.info(f"检测到广告弹窗,准备关闭: {ad_res}")
|
||||
d.click(ad_res['x'], ad_res['y'])
|
||||
await asyncio.sleep(1.5)
|
||||
ad_type = ad_res.get("ad_type")
|
||||
logger.info(f"检测到广告弹窗,准备关闭: {ad_res} [Type: {ad_type}]")
|
||||
|
||||
x, y = ad_res['x'], ad_res['y']
|
||||
|
||||
if ad_type == "rabbit":
|
||||
logger.info(">>> 检测到顽固的兔子广告,执行强力双击策略...")
|
||||
# 使用 u2 的 double_click,它比两次 click + sleep 更快
|
||||
d.double_click(x, y, duration=0.05)
|
||||
|
||||
# 处理“误触背景卡片”的逻辑:既然可能进去了,就等一会儿再退出来
|
||||
logger.info(">>> 考虑到可能误触背景卡片,等待 2s 后执行返回操作...")
|
||||
await asyncio.sleep(2.0)
|
||||
d.press("back")
|
||||
await asyncio.sleep(1.0)
|
||||
logger.info(">>> 已尝试从误触页面返回。")
|
||||
else:
|
||||
d.click(x, y)
|
||||
await asyncio.sleep(1.5)
|
||||
# 重新截图
|
||||
if os.path.exists(screenshot_path): os.remove(screenshot_path)
|
||||
screenshot_path = take_screenshot(d, image_uuid, save_dir=TEMP_IMAGE_DIR)
|
||||
|
||||
@@ -61,8 +61,25 @@ async def check_and_close_ad(d):
|
||||
ad_result = await ReadImageKit.detect_ad_popup(screenshot_path, device_info=device_info)
|
||||
if ad_result:
|
||||
x, y = ad_result["x"], ad_result["y"]
|
||||
logger.info(f"通过视觉大模型检测到广告关闭按钮: ({x}, {y})")
|
||||
d.click(x, y)
|
||||
ad_type = ad_result.get("ad_type")
|
||||
|
||||
logger.info(f"通过视觉大模型检测到广告关闭按钮: ({x}, {y}) [Type: {ad_type}]")
|
||||
|
||||
# 针对“新电兔AI”兔子广告的强力关闭策略
|
||||
if ad_type == "rabbit":
|
||||
logger.info(">>> 检测到顽固的兔子广告,执行强力双击策略...")
|
||||
# 使用 u2 的 double_click,它比两次 click + sleep 更快
|
||||
d.double_click(x, y, duration=0.05)
|
||||
|
||||
# 处理“误触背景卡片”的逻辑
|
||||
logger.info(">>> 考虑到可能误触背景卡片,等待 2s 后执行返回操作...")
|
||||
await asyncio.sleep(2.0)
|
||||
d.press("back")
|
||||
await asyncio.sleep(1.0)
|
||||
logger.info(">>> 已尝试从误触页面返回。")
|
||||
else:
|
||||
d.click(x, y)
|
||||
|
||||
if os.path.exists(screenshot_path):
|
||||
os.remove(screenshot_path)
|
||||
return True
|
||||
|
||||
@@ -129,9 +129,14 @@ class ReadImageKit:
|
||||
if result.get("has_ad") and result.get("close_point"):
|
||||
if result.get("ad_type") == "rabbit":
|
||||
logger.info("大模型找到了兔子广告!")
|
||||
# 强制使用固定坐标 (94, 830) - 归一化 0-1000
|
||||
# 根据多次 CV 测试结果 (94, 828) 和 (93, 830) 的综合评估
|
||||
logger.info(">>> 采用强制固定坐标策略 (94, 830) 以确保点击准确性")
|
||||
norm_point = [94, 830]
|
||||
else:
|
||||
norm_point = result["close_point"]
|
||||
|
||||
# 转换坐标
|
||||
norm_point = result["close_point"]
|
||||
if len(norm_point) == 2:
|
||||
if not device_info:
|
||||
device_info = cls._FALLBACK_DEVICE_INFO
|
||||
@@ -143,7 +148,11 @@ class ReadImageKit:
|
||||
x = int(norm_point[0] / 1000 * w)
|
||||
y = int(norm_point[1] / 1000 * h)
|
||||
|
||||
return {"x": x, "y": y}
|
||||
return {
|
||||
"x": x,
|
||||
"y": y,
|
||||
"ad_type": result.get("ad_type", "unknown")
|
||||
}
|
||||
|
||||
return None
|
||||
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user