import json
ep = json.load(open("小说2/storyboard-work/ep-01.json",encoding="utf-8"))
seg = next(s for s in ep["segments"] if s["id"]=="E01-05")
for i,c in enumerate(seg["cuts"],1):
    print("#%d beats=%s secs=%s" % (i, c["beats"], c["seconds"]))
sc = next(x for x in ep["seedScenes"] if x["sceneIndex"]==seg["sceneIndex"])
# dialogue per cut
for i,c in enumerate(seg["cuts"],1):
    a,b = c["beats"]
    dlg = sum(x["seconds"] for x in sc["beats"] if a<=x["n"]<=b and x.get("kind")=="line")
    print("#%d dlg=%.2f slack=%.2f" % (i, dlg, c["seconds"]-dlg))
