#!/usr/bin/env python3
"""Cek kategori post kontrak + timezone situs + jadwal future terakhir."""
import base64, json, urllib.request
S = "https://studiosoft.id"
AUTH = base64.b64encode(b"bambangbot:q26r RePo BVy6 pwU2 F3z7 ouyl").decode()
UA = {"User-Agent": "Mozilla/5.0"}
def rest(p):
    r = urllib.request.Request(S + p, headers={"Authorization": f"Basic {AUTH}", **UA})
    with urllib.request.urlopen(r, timeout=120) as x:
        return json.loads(x.read())
root = rest("/wp-json/")
print("timezone:", root.get("timezone_string"), root.get("gmt_offset"))
d = rest("/wp-json/wp/v2/posts?slug=kontrak-digital-agency-pasal-wajib&status=any&_fields=id,status,date,date_gmt,categories,tags")
print("kontrak:", json.dumps(d, ensure_ascii=False))
d2 = rest("/wp-json/wp/v2/posts?status=future&per_page=100&orderby=date&order=asc&_fields=id,date,slug,categories")
print("future count:", len(d2))
print("future terakhir:", json.dumps(d2[-3:], ensure_ascii=False))
