add refresh_balances/diag, tokens_guard (single UPDATE), priority notes; 70 accounts live
This commit is contained in:
@@ -47,6 +47,33 @@ def bm_post(path, key, obj):
|
||||
return json.loads(r.read().decode())
|
||||
|
||||
|
||||
def pull_recent(product, pages=3, since=None):
|
||||
"""Все покупки по продукту со страниц /purchases (per_page=100)."""
|
||||
key = bm_key()
|
||||
if not key:
|
||||
return []
|
||||
out = []
|
||||
for page in range(1, pages + 1):
|
||||
d = bm_get(f"/purchases?per_page=100&page={page}", key)
|
||||
rows = d.get("data") or []
|
||||
if not rows:
|
||||
break
|
||||
for it in rows:
|
||||
if it.get("product_id") != product:
|
||||
continue
|
||||
sold = it.get("sold_at") or ""
|
||||
if since and sold < since:
|
||||
continue
|
||||
raw = str(it.get("data") or "").strip()
|
||||
if "|" in raw:
|
||||
email, pw = raw.split("|")[0].strip(), raw.split("|")[1].strip()
|
||||
else:
|
||||
continue
|
||||
if "@" in email:
|
||||
out.append(f"{email}|{pw}")
|
||||
return out
|
||||
|
||||
|
||||
def buy(n, product):
|
||||
key = bm_key()
|
||||
if not key:
|
||||
@@ -124,6 +151,8 @@ if __name__ == "__main__":
|
||||
ap = argparse.ArgumentParser()
|
||||
ap.add_argument("--buy", type=int, default=0)
|
||||
ap.add_argument("--product", type=int, default=578)
|
||||
ap.add_argument("--pull", type=int, default=0, help="страниц /purchases по продукту")
|
||||
ap.add_argument("--since", default=None, help="ISO-время, например 2026-11-14T12:00:00")
|
||||
ap.add_argument("--file", default=None)
|
||||
ap.add_argument("--check", action="store_true")
|
||||
a = ap.parse_args()
|
||||
@@ -132,9 +161,10 @@ if __name__ == "__main__":
|
||||
D.log(f"buy {a.buy} x product {a.product}")
|
||||
lines = buy(a.buy, a.product)
|
||||
D.log("got:", len(lines))
|
||||
for l in lines:
|
||||
D.log(" ", l.split("|")[0])
|
||||
D.log("added:", append_accounts(lines))
|
||||
if a.pull:
|
||||
lines = pull_recent(a.product, a.pull, a.since)
|
||||
D.log("pull:", len(lines), "added:", append_accounts(lines))
|
||||
if a.file:
|
||||
lines = from_file(a.file)
|
||||
D.log("from file:", len(lines), "added:", append_accounts(lines))
|
||||
|
||||
Reference in New Issue
Block a user