import os, sys, json, time, logging
logging.basicConfig(level=logging.INFO)

with open('.env', 'r') as f:
    for line in f:
        line = line.strip()
        if not line or line.startswith('#') or '=' not in line:
            continue
        k, _, v = line.partition('=')
        os.environ.setdefault(k.strip(), v.strip().strip('"').strip("'"))

sys.path.insert(0, '.')

start = time.time()
from videoautomation.script_generator import generate_script

script = generate_script('Create a 60-second promo video about BizNode AI chatbot features and pricing')
elapsed = time.time() - start

print("Time: %.1fs" % elapsed)
print("Title:", script.get("title", "(none)"))
print("Scenes:", script.get("total_scenes", 0))
for s in script.get("scenes", []):
    vo_len = len(s.get("voiceover", ""))
    t = s.get("title", "(no title)")
    print("  %s | %s | %s | vo:%d chars" % (s.get("id", "?"), s.get("visual_type", "?"), t, vo_len))
