import os

EPISODES = [
    "EP01_Cannae_216BC",
    "EP02_Gaugamela_331BC",
    "EP03_Alesia_52BC",
    "EP04_Teutoburg_9AD",
    "EP05_Catalaunian_451AD",
    "EP06_Yarmouk_636AD",
    "EP07_Hastings_1066",
    "EP08_Hattin_1187",
    "EP09_Kalka_1223",
    "EP10_Bach_Dang_1288",
    "EP11_Constantinople_1453",
    "EP12_Sekigahara_1600",
    "EP13_Breitenfeld_1631",
    "EP14_Vienna_1683",
    "EP15_Leuthen_1757",
    "EP16_Austerlitz_1805",
    "EP17_Borodino_1812",
    "EP18_Waterloo_1815",
    "EP19_Gettysburg_1863",
    "EP20_Sedan_1870",
    "EP21_Tannenberg_1914",
    "EP22_Midway_1942",
    "EP23_Stalingrad_1942",
    "EP24_Kursk_1943",
    "EP25_Bulge_1944",
    "EP26_Chosin_1950",
    "EP27_Dien_Bien_Phu_1954",
    "EP28_Chinese_Farm_1973",
    "EP29_Desert_Storm_1991",
    "EP30_Grozny_1994"
]

SUBFOLDERS = [
    "01_Script",
    "02_Map_Data",
    "03_Timeline_Data",
    "04_Audio_Voice",
    "05_Renders",
    "06_Master_Output"
]

def create_structure():
    base_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), "episodes")
    os.makedirs(base_dir, exist_ok=True)
    count = 0
    for ep in EPISODES:
        ep_dir = os.path.join(base_dir, ep)
        for sub in SUBFOLDERS:
            path = os.path.join(ep_dir, sub)
            os.makedirs(path, exist_ok=True)
        # Tạo sẵn file README.md cho mỗi tập
        readme_path = os.path.join(ep_dir, "README.md")
        if not os.path.exists(readme_path):
            with open(readme_path, "w", encoding="utf-8") as f:
                f.write(f"# {ep.replace('_', ' ')}\n\nTrạng thái: Khởi tạo cấu trúc sản xuất 6 tầng.\nThời lượng chuẩn: 28 - 32 phút.\n")
        count += 1
    print(f"[OK] Successfully initialized {count} episode directories with full production subfolders.")

if __name__ == "__main__":
    create_structure()
