#!/usr/bin/env python3
"""Cari kredensial yang benar untuk studiosoft.id dari beberapa kandidat di workspace."""
import base64, json, urllib.error, urllib.request

UA = {"User-Agent": "Mozilla/5.0"}
KANDIDAT = [
    ("ss_ai_series", "q26r RePo BVy6 pwU2 F3z7 ouyl"),
    ("leit", "zibd dLIV xY8x onP9 39qL hiNr"),
    ("yasma", "LFp4 LXBh kMYG 84qC 2DDc 5bLc"),
    ("tslaw", "EFKm EYGx VQCP Y9go ncPr uM2Y"),
    ("ssc", "r4bI jsIF CsAn uTIz SlFa TnJz"),
]

for nama, pw in KANDIDAT:
    auth = base64.b64encode(f"bambangbot:{pw}".encode()).decode()
    r = urllib.request.Request("https://studiosoft.id/wp-json/wp/v2/users/me?context=edit",
                               headers={"Authorization": f"Basic {auth}", **UA})
    try:
        with urllib.request.urlopen(r, timeout=60) as x:
            d = json.loads(x.read())
            cap = d.get("capabilities") or {}
            penting = [k for k in ("create_posts", "edit_posts", "publish_posts", "manage_options", "upload_files") if cap.get(k)]
            print(f"   ✅ {nama:<14} id {d.get('id')} | {d.get('name')} | peran {d.get('roles')} | {penting}")
    except urllib.error.HTTPError as e:
        print(f"   ❌ {nama:<14} HTTP {e.code}")
    except Exception as e:
        print(f"   ❌ {nama:<14} {str(e)[:50]}")
