From dd4d5571e2c7871665004f1e7b13aa4493d3974f Mon Sep 17 00:00:00 2001 From: yuming Date: Fri, 18 Sep 2026 22:38:11 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E7=82=B9=E5=87=BB=E5=89=8D=E6=A3=80?= =?UTF-8?q?=E6=B5=8B=E4=B8=8B=E8=BD=BD=E9=98=9F=E5=88=97=E7=BA=A2=E7=82=B9?= =?UTF-8?q?=EF=BC=8C=E9=98=9F=E5=88=97=E5=BF=99=E6=97=B6=E7=AD=89=E5=BE=85?= =?UTF-8?q?=E6=B6=88=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 之前不检测队列状态,队列满了还继续点击新卡片, 新点击被拒绝永远不打勾,空等6分钟后滚动走导致漏下载。 现在每轮截图后先检测右上角红点: - 有红点=队列忙,等待最多5分钟让队列消化 - 红点消失后再点击新卡片 --- automate.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/automate.py b/automate.py index 9b6625b..cca4751 100644 --- a/automate.py +++ b/automate.py @@ -346,6 +346,25 @@ def get_checked_cells_dynamic(png_path, row_centers): return checked +def is_queue_busy(png_path): + """检测右上角是否有红色感叹号(下载队列忙)。 + 有红点说明队列已满/有后台任务,此时不应再点击新卡片, + 否则新点击会被拒绝且永远不会打勾。""" + try: + with Image.open(png_path) as img: + img = img.convert("RGB") + w, h = img.size + # 右上角下载图标区域 + x0, y0 = int(w*0.92), int(h*0.37) + x1, y1 = int(w*0.99), int(h*0.40) + region = img.crop((x0, y0, x1, y1)) + pixels = list(region.getdata()) + red = sum(1 for r,g,b in pixels if r>180 and g<80 and b<80) + return red > 30 + except Exception: + return False + + def count_checked_badges(png_path): """统计整屏已打勾(蓝色角标)的卡片数量。 先用 detect_card_rows 检测实际行位置,再逐行逐列检测打勾, @@ -701,6 +720,17 @@ def tap_all_thumbnails(baseline, max_rounds=300, poll_interval=4, max_wait_per_r # 每屏动态实测卡片行中心 y(消除整点分组标签平移造成的错位,这是"重复下载" # 的总根源),再对每行 × 固定 3 列逐格判打勾,只点还没下载完的。 grid_shot = screenshot("/tmp/_gridchk.png") + # 队列忙等待:右上角有红点说明下载队列已满,新点击会被拒绝。 + # 先等队列消化(最多5分钟),红点消失后再继续,避免空等6分钟后滚动走。 + queue_wait = 0 + while is_queue_busy(grid_shot) and queue_wait < 300: + if queue_wait % 30 == 0: + print(f" 轮 {r+1}: 下载队列忙(右上角红点),等待队列消化... {queue_wait}s") + time.sleep(10) + queue_wait += 10 + grid_shot = screenshot("/tmp/_gridchk.png") + if is_queue_busy(grid_shot): + print(f" 轮 {r+1}: 等待 {queue_wait}s 后队列仍忙,照常滚动(靠下游去重兜底)") full_rows = detect_card_rows(grid_shot) # 检测不到行时重试最多3次:缩略图加载慢、ANR刚恢复、画面切换中都会导致 # 临时检测不到行。之前只重试1次就放弃,会误判"全部已打勾"直接滚动,