#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""Lihat kategori & tag artikel tslaw.id yang bersinggungan topik tanah/waris."""
import json
import sys

sys.path.insert(0, "/home/mantapman/.hermes/profiles/atun/workspace")
import tslaw_wp as T  # noqa: E402

for pid in (2942, 2904, 3350, 2823, 3228):
    try:
        r = T.get(f"posts/{pid}", {"context": "edit",
                                   "_fields": "id,slug,title,status,categories,tags,link"})
        j = r.json()
        print(f"#{pid} {j['title']['rendered'][:60]}")
        print(f"     status={j.get('status')} kategori={j.get('categories')} tag={j.get('tags')}")
    except Exception as e:
        print(f"#{pid} GAGAL: {e}")

print("\n=== kategori (nama -> id) ===")
for c in T.kategori():
    print(f"  {c['id']}: {c['name']} ({c['count']})")
