#!/usr/bin/env python3
"""Create the seven overnight reel folders: SCRIPT.md, caption.txt, spec.json, cut.json."""
import json, pathlib

REELS = "/Users/sarthakrawool/Documents/Agency/products/restorebunny/reels"
MUSIC = {"file": "/Users/sarthakrawool/Documents/Content/music/production/legacy_slowed.mp3", "start": 60.0}
CTA = "Want yours fixed like this? Comment restore. I'll send the link."
FIX = {"restorebunny": "RESTOREBUNNY", "priya": "PRIYA", "sam": "SAM", "nan": "NAN"}

REELS_DATA = [
    {
        "slug": "2026-12-06-the-house-key",
        "title": "The House Key",
        "feeling": "everyone who has handed back the keys to a home they grew up in will send this to the sibling who packed the boxes.",
        "lines": [
            ("g01", "sam", "The new owners want the keys back tomorrow. That's the end of it."),
            ("g02", "priya", "Nan, was this your old flat? Number twelve, with the blue door?"),
            ("g03", "nan", "That's my kitchen window. I hung the washing out of that window."),
            ("g04", "priya", "RestoreBunny pulled the cracked corner back. It's the whole street."),
            ("g05", "nan", "There's Mrs Doyle's rose bush. She never once let me touch it."),
            ("g06", "sam", "I said we'd lost that blue door. I was wrong to rush you."),
            ("g07", "priya", CTA),
        ],
        "caption": [
            "The new owners want the keys back tomorrow.",
            "Nan's flat, a blue door, and a corner of the photo that had cracked away.",
            "A fictional story, animated with AI.",
            "Fix your old family photos: restorebunny.com (link in bio)",
            "What would you want to see again from a house you left?",
            "#oldphotos #photorestoration #familyhistory #restorebunny #animatedstory",
        ],
    },
    {
        "slug": "2026-12-06-the-blank-wallet",
        "title": "The Blank Wallet",
        "feeling": "anyone with a parent who never smiled in photos will send this to the person who still says he was a hard man.",
        "lines": [
            ("g01", "priya", "Dad's old wallet. The photo inside has gone completely white."),
            ("g02", "sam", "He carried that thing thirty years. Never told me who it was."),
            ("g03", "priya", "RestoreBunny brought the shape back. Look at his face, Sam."),
            ("g04", "nan", "That's your father laughing. He never laughed in a photograph."),
            ("g05", "sam", "I spent years telling people he never smiled. I was sure."),
            ("g06", "sam", "That's him. He was happy once, and I never knew it."),
            ("g07", "priya", CTA),
        ],
        "caption": [
            "Dad's wallet. The photo inside has gone completely white.",
            "Thirty years in a back pocket, and a face nobody in the family had seen.",
            "A fictional story, animated with AI.",
            "Fix your old family photos: restorebunny.com (link in bio)",
            "Who in your family do the photos get wrong?",
            "#oldphotos #photorestoration #familyhistory #restorebunny #animatedstory",
        ],
    },
    {
        "slug": "2026-12-06-the-two-copies",
        "title": "The Two Copies",
        "feeling": "every sibling who owns a different version of the same wedding photo will send this to the one who swears theirs is the original.",
        "lines": [
            ("g01", "sam", "I've got the only copy of Mum's wedding day. You don't."),
            ("g02", "priya", "Then why does mine have a man standing at the back?"),
            ("g03", "sam", "That's impossible. Mine's cropped right at the edge there."),
            ("g04", "priya", "RestoreBunny rebuilt the whole frame. That's Grandad, Sam."),
            ("g05", "nan", "He walked your mum down the aisle. You never saw his face."),
            ("g06", "sam", "I cropped Grandad out and blamed the photograph. I did that."),
            ("g07", "priya", CTA),
        ],
        "caption": [
            "I've got the only copy of Mum's wedding day.",
            "Two siblings, two versions of one photograph, and a man at the back of hers.",
            "A fictional story, animated with AI.",
            "Fix your old family photos: restorebunny.com (link in bio)",
            "Which copy in your family turned out to be the cut one?",
            "#oldphotos #photorestoration #familyhistory #restorebunny #animatedstory",
        ],
    },
    {
        "slug": "2026-12-06-nans-shop",
        "title": "Nan's Shop",
        "feeling": "everyone whose grandmother ran a shop nobody photographed will send this to the cousin who still remembers the sign.",
        "lines": [
            ("g01", "priya", "Nan asked for one thing for her birthday. A photo of the shop."),
            ("g02", "sam", "The shop shut in ninety-eight. There's nothing left of it now."),
            ("g03", "priya", "There's one print. Torn in half, in the shoebox in the loft."),
            ("g04", "sam", "RestoreBunny joined both halves. Look, the sign is back."),
            ("g05", "nan", "My name was painted over that door for twenty years."),
            ("g06", "nan", "I thought nobody remembered that shop except me."),
            ("g07", "priya", CTA),
        ],
        "caption": [
            "Nan asked for one thing for her birthday. A photo of the shop.",
            "It shut in 1998, and the only print had been torn in half for thirty years.",
            "A fictional story, animated with AI.",
            "Fix your old family photos: restorebunny.com (link in bio)",
            "What shop do you wish someone had photographed?",
            "#oldphotos #photorestoration #familyhistory #restorebunny #animatedstory",
        ],
    },
    {
        "slug": "2026-12-06-the-fair-ribbon",
        "title": "The Fair Ribbon",
        "feeling": "anyone who has outlived a sister will send this to the niece who never met her.",
        "lines": [
            ("g01", "nan", "There were two of us at that fair. The photo only shows me."),
            ("g02", "priya", "Someone's cut off at the shoulder. Who was standing there?"),
            ("g03", "nan", "My sister Rose. She died the winter after that summer."),
            ("g04", "priya", "RestoreBunny opened the frame out. There she is, Nan."),
            ("g05", "nan", "She's wearing my ribbon. I gave it to her that morning."),
            ("g06", "nan", "Forty years I've told that story. Now I can see her."),
            ("g07", "priya", CTA),
        ],
        "caption": [
            "There were two of us at that fair. The photo only shows me.",
            "A shoulder at the edge of the frame, and a sister Nan hadn't seen in forty years.",
            "A fictional story, animated with AI.",
            "Fix your old family photos: restorebunny.com (link in bio)",
            "Who is missing from the edge of your family photos?",
            "#oldphotos #photorestoration #familyhistory #restorebunny #animatedstory",
        ],
    },
    {
        "slug": "2026-12-06-the-school-photo",
        "title": "The School Photo",
        "feeling": "anyone who sat next to their mother at school will send this to the brother who never talks about it.",
        "lines": [
            ("g01", "priya", "Sam, you were in the same class as Mum? You never said."),
            ("g02", "sam", "One year, then she moved. I've got the class photo somewhere."),
            ("g03", "priya", "Half of it's water damaged. Everyone's faces are gone."),
            ("g04", "sam", "RestoreBunny cleaned it. Back row, third from the left. Her."),
            ("g05", "sam", "She's pulling a face at the camera. She never did that at home."),
            ("g06", "sam", "I sat two seats from her for a year and forgot her face."),
            ("g07", "priya", CTA),
        ],
        "caption": [
            "You were in the same class as Mum? You never said.",
            "A water-damaged school photo, and a face Sam had been sitting next to his whole life.",
            "A fictional story, animated with AI.",
            "Fix your old family photos: restorebunny.com (link in bio)",
            "What do your parents look like in photos you've never seen?",
            "#oldphotos #photorestoration #familyhistory #restorebunny #animatedstory",
        ],
    },
    {
        "slug": "2026-12-06-the-last-print",
        "title": "The Last Print",
        "feeling": "anyone who found a tin of negatives nobody ever printed will send this to the person who still has the tin.",
        "lines": [
            ("g01", "priya", "The tin in the loft had forty negatives and no prints at all."),
            ("g02", "sam", "Forty? Mum never had the money to print any of those."),
            ("g03", "priya", "RestoreBunny picked one. It's Nan on a bicycle, laughing."),
            ("g04", "nan", "That's the bike your grandfather built. It never had brakes."),
            ("g05", "sam", "She's laughing with her eyes shut. I've never seen that."),
            ("g06", "nan", "I'd forgotten I ever laughed like that. I was so young."),
            ("g07", "priya", CTA),
        ],
        "caption": [
            "The tin in the loft had forty negatives and no prints at all.",
            "Forty photographs Mum never paid to print, and one bicycle with no brakes.",
            "A fictional story, animated with AI.",
            "Fix your old family photos: restorebunny.com (link in bio)",
            "Have you ever found the negatives but not the prints?",
            "#oldphotos #photorestoration #familyhistory #restorebunny #animatedstory",
        ],
    },
]

for r in REELS_DATA:
    d = pathlib.Path(REELS) / r["slug"]
    d.mkdir(parents=True, exist_ok=True)
    (d / "refs").mkdir(exist_ok=True)
    (d / "env").mkdir(exist_ok=True)
    (d / "plates").mkdir(exist_ok=True)
    (d / "clips").mkdir(exist_ok=True)
    (d / "edit").mkdir(exist_ok=True)

    rows = "\n".join(
        f"| {k} | **{who.capitalize()}**: \"{text}\" |" for k, who, text in r["lines"]
    )
    (d / "SCRIPT.md").write_text(
        f"# {r['title']}\n\nFeeling first: {r['feeling']}\n\n| gen | line |\n|---|---|\n{rows}\n"
    )
    (d / "caption.txt").write_text("\n".join(r["caption"]) + "\n")

    spec = {
        "id": r["slug"],
        "product": "restorebunny",
        "title": r["title"],
        "payoff": "g06",
        "caption_style": "clean",
        "music": MUSIC,
        "sfx": {"auto": True, "music_db": 9},
    }
    (d / "spec.json").write_text(json.dumps(spec, indent=1))

    shots = []
    for i, (k, who, text) in enumerate(r["lines"]):
        s = {"k": k, "line": text}
        if k == "g04":
            s["transition"] = "flash"
        if k == "g06":
            s["transition"] = "whip"
        if k == "g07":
            s["tail"] = 0.6
        shots.append(s)
    cut = {"shots": shots, "fix": FIX, "payoff": "g06", "style": "clean", "tail": 0.12, "speed": 1.0}
    (d / "cut.json").write_text(json.dumps(cut, indent=1))

    print("built", d.name)
