#!/usr/bin/env python3
import urllib.request, json

BASE = "https://ota.46-4-121-190.sslip.io"
def call(m, u, d=None, t=None):
    h = {"Content-Type": "application/json"}
    if t: h["Authorization"] = f"Bearer {t}"
    req = urllib.request.Request(u, data=(json.dumps(d).encode() if d else None), headers=h, method=m)
    with urllib.request.urlopen(req, timeout=30) as r: return json.loads(r.read())

tok = call("POST", f"{BASE}/authentication", {"strategy":"local","username":"admin","password":"353fde0a0fe4e8a0b2799e54"})["accessToken"]
d = call("GET", f"{BASE}/uploads", t=tok)
u = d.get("data", d) if isinstance(d, dict) else d
v111 = [x for x in u if x.get("version") == "1.0.111"]
v111.sort(key=lambda x: x.get("createdAt", ""))
print("=== 1.0.111 uploads chronological ===")
for x in v111:
    print(x["_id"], x.get("updateId"), "created=", x.get("createdAt"), "status=", x.get("status"), "commit=", x.get("gitCommit"))
