#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import json, os

D = "/data/www/files"
projs = json.load(open(D + "/projects_20260917.json", encoding="utf-8"))
SH, SN = D + "/screenshots/20260917", D + "/snapshots/20260917"
good, bad = [], []
for i, p in enumerate(projs, 1):
    f = os.path.join(SH, "p%02d.png" % i)
    t = os.path.join(SN, "s%02d.txt" % i)
    s = os.path.getsize(f) if os.path.exists(f) else 0
    tl = os.path.getsize(t) if os.path.exists(t) else 0
    body = ""
    if tl:
        body = open(t, encoding="utf-8", errors="ignore").read()
    dead = ("暂无数据" in body) or ("正在加载" in body and tl < 900)
    ok = s >= 100000 and tl > 400 and not dead
    (good if ok else bad).append((i, s, tl, dead, p["province"], p["title"][:34]))

print("GOOD=%d BAD=%d" % (len(good), len(bad)))
print("\n--- GOOD ---")
for g in good:
    print("  #%02d %7dB %5dB %s %s" % (g[0], g[1], g[2], g[4], g[5]))
print("\n--- BAD ---")
for b in bad:
    print("  #%02d %7dB %5dB dead=%s %s %s" % (b[0], b[1], b[2], b[3], b[4], b[5]))
