fix: 点击前检测下载队列红点,队列忙时等待消化

之前不检测队列状态,队列满了还继续点击新卡片,
新点击被拒绝永远不打勾,空等6分钟后滚动走导致漏下载。

现在每轮截图后先检测右上角红点:
- 有红点=队列忙,等待最多5分钟让队列消化
- 红点消失后再点击新卡片
This commit is contained in:
yuming
2026-09-18 22:38:11 +08:00
parent 68847167dd
commit dd4d5571e2
+30
View File
@@ -346,6 +346,25 @@ def get_checked_cells_dynamic(png_path, row_centers):
return checked 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): def count_checked_badges(png_path):
"""统计整屏已打勾(蓝色角标)的卡片数量。 """统计整屏已打勾(蓝色角标)的卡片数量。
先用 detect_card_rows 检测实际行位置,再逐行逐列检测打勾, 先用 detect_card_rows 检测实际行位置,再逐行逐列检测打勾,
@@ -701,6 +720,17 @@ def tap_all_thumbnails(baseline, max_rounds=300, poll_interval=4, max_wait_per_r
# 每屏动态实测卡片行中心 y(消除整点分组标签平移造成的错位,这是"重复下载" # 每屏动态实测卡片行中心 y(消除整点分组标签平移造成的错位,这是"重复下载"
# 的总根源),再对每行 × 固定 3 列逐格判打勾,只点还没下载完的。 # 的总根源),再对每行 × 固定 3 列逐格判打勾,只点还没下载完的。
grid_shot = screenshot("/tmp/_gridchk.png") 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) full_rows = detect_card_rows(grid_shot)
# 检测不到行时重试最多3次:缩略图加载慢、ANR刚恢复、画面切换中都会导致 # 检测不到行时重试最多3次:缩略图加载慢、ANR刚恢复、画面切换中都会导致
# 临时检测不到行。之前只重试1次就放弃,会误判"全部已打勾"直接滚动, # 临时检测不到行。之前只重试1次就放弃,会误判"全部已打勾"直接滚动,