'commit'
This commit is contained in:
@@ -168,10 +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)
|
||||
|
||||
ad_top_y_norm = 0.90 # 默认使用一个更宽松的底部边界 (0.90),防止点到导航栏
|
||||
ad_top_y_norm = 0.78 # 恢复默认的点击边界 (0.78),不再需要为了避开兔子而设为 0.90
|
||||
if ad_res:
|
||||
ad_type = ad_res.get("ad_type")
|
||||
if ad_type != "rabbit":
|
||||
if ad_type == "rabbit":
|
||||
logger.info(">>> 检测到兔子广告。尝试使用图片识别关闭...")
|
||||
try:
|
||||
# 使用基于图片的关闭方案
|
||||
template_path = os.path.join(os.path.dirname(__file__), "Template", "X.jpg")
|
||||
if d.image.click(template_path, timeout=3.0):
|
||||
logger.info(">>> 成功通过图片识别关闭兔子广告。")
|
||||
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)
|
||||
else:
|
||||
logger.warning(">>> 图片识别未找到兔子广告关闭按钮。")
|
||||
except Exception as ex:
|
||||
logger.error(f">>> 图片识别关闭兔子广告异常: {ex}")
|
||||
else:
|
||||
x, y = ad_res['x'], ad_res['y']
|
||||
logger.info(f"检测到非兔子广告: {ad_res} [Type: {ad_type}],正在关闭...")
|
||||
d.click(x, y)
|
||||
@@ -179,11 +194,6 @@ async def get_station_list(d, service, uploader, max_scrolls=MAX_SCROLLS):
|
||||
# 重新截图
|
||||
if os.path.exists(screenshot_path): os.remove(screenshot_path)
|
||||
screenshot_path = take_screenshot(d, image_uuid, save_dir=TEMP_IMAGE_DIR)
|
||||
else:
|
||||
# 发现兔子广告,不再尝试关闭,直接计算它的顶边界 (归一化 0-1)
|
||||
# 我们取 0.90 作为安全阈值,低于此 Y 坐标的场站认为被遮挡
|
||||
ad_top_y_norm = 0.90
|
||||
logger.info(f">>> 发现兔子广告,设定安全边界为 Y_norm < {ad_top_y_norm}")
|
||||
|
||||
# 检查是否已经滚动到底部 (排除状态栏后,内容与上次一致)
|
||||
current_md5 = Kit.get_image_content_md5(
|
||||
@@ -270,7 +280,19 @@ async def get_station_list(d, service, uploader, max_scrolls=MAX_SCROLLS):
|
||||
if detail_ad_res:
|
||||
dad_type = detail_ad_res.get("ad_type")
|
||||
if dad_type == "rabbit":
|
||||
logger.info(">>> 详情页检测到 rabbit 广告。根据策略,我们不再尝试关闭它,直接继续。")
|
||||
logger.info(">>> 详情页检测到 rabbit 广告。尝试使用图片识别关闭...")
|
||||
try:
|
||||
template_path = os.path.join(os.path.dirname(__file__), "Template", "X.jpg")
|
||||
if d.image.click(template_path, timeout=3.0):
|
||||
logger.info(">>> 详情页成功通过图片识别关闭兔子广告。")
|
||||
await asyncio.sleep(1.5)
|
||||
# 重新截图
|
||||
if os.path.exists(detail_path): os.remove(detail_path)
|
||||
detail_path = take_screenshot(d, detail_uuid, save_dir=TEMP_IMAGE_DIR)
|
||||
else:
|
||||
logger.warning(">>> 详情页图片识别未找到兔子广告关闭按钮,跳过。")
|
||||
except Exception as ex:
|
||||
logger.error(f">>> 详情页图片识别关闭兔子广告异常: {ex}")
|
||||
else:
|
||||
dx, dy = detail_ad_res["x"], detail_ad_res["y"]
|
||||
logger.info(f"检测到详情页弹窗: {dad_type},正在点击关闭 ({dx}, {dy})...")
|
||||
|
||||
Reference in New Issue
Block a user