#!/usr/bin/env python3
import json, datetime
docs = json.load(open('/tmp/tsc_sched_all.json'))
TSC_IG = "6a86a7e062caae1e04ff8244"
WIB = datetime.timezone(datetime.timedelta(hours=7))
ig = [d for d in docs if d.get('accountId') == TSC_IG]
def w(iso):
    return datetime.datetime.fromisoformat(iso.replace('Z', '+00:00')).astimezone(WIB)
for d in sorted(ig, key=lambda x: x.get('scheduleAt') or ''):
    t = w(d['scheduleAt']) if d.get('scheduleAt') else None
    print((t.strftime('%Y-%m-%d %H:%M') if t else '?'), d.get('status'), d.get('type'),
          (d.get('title') or '')[:30], 'media=%d' % len(d.get('medias') or []))
