Onur Kansoy
Final polish: accelerated intro, integrated curtains, and hidden audio UI
192e13c verified | import os | |
| import json | |
| import sys | |
| from pathlib import Path | |
| sys.path.insert(0, str(Path(__file__).parent.parent)) | |
| import core.playwright as pw | |
| from core.image_generator import ImageGenerator | |
| from dotenv import load_dotenv | |
| load_dotenv() | |
| OPENROUTER_API_KEY = os.environ.get("OPENROUTER_API_KEY") | |
| PRESETS = { | |
| "british_comedy": "A 4-scene British comedy about a disastrous dinner party.", | |
| "infidelity": "A 4-scene tense modern drama about a husband discovering his wife's infidelity during a casual evening.", | |
| "victorian_drama": "A 4-scene gripping Victorian drama about a disputed inheritance in a rainy countryside estate." | |
| } | |
| def main(): | |
| Path("presets").mkdir(exist_ok=True) | |
| Path("preset_images").mkdir(exist_ok=True) | |
| img_gen = ImageGenerator(OPENROUTER_API_KEY) | |
| for key, topic in PRESETS.items(): | |
| print(f"Generating script for {key}...") | |
| try: | |
| script = pw.generate_script(topic, OPENROUTER_API_KEY) | |
| for i, scene in enumerate(script.get("scenes", [])): | |
| rel_path = f"preset_images/{key}_scene_{i+1}.png" | |
| scene["image_path"] = rel_path | |
| print(f" Generating image for scene {i+1}...") | |
| try: | |
| img_gen.generate(scene["image_prompt"], rel_path) | |
| except Exception as e: | |
| print(f" [IMG Error] {e}") | |
| out_path = Path("presets") / f"{key}.json" | |
| with open(out_path, "w") as f: | |
| json.dump(script, f, indent=2) | |
| print(f"Saved {out_path}") | |
| except Exception as e: | |
| print(f"Error generating {key}: {e}") | |
| if __name__ == "__main__": | |
| main() | |