#!/usr/bin/env python3
"""
WordPress Poster via Browser Automation
Bypasses REST API restrictions by logging into WordPress admin
"""
import asyncio
from playwright.async_api import async_playwright

async def post_article():
    article = {
        "title": "Never Too Old to Explore: Immersia XR Redefines Virtual Reality for All Ages",
        "content": """<p><strong>Step into a world where age is just a number and adventure knows no bounds.</strong></p>

<p>At Immersia XR, we believe that the magic of immersive experiences should be accessible to everyone—regardless of age. Our latest installation proves just that: three women, dressed in everything from elegant black coats to bold leopard print, standing together in a vibrant VR wonderland, looking down through their headsets with pure wonder and curiosity.</p>

<h2>A Pop-Art Wonderland</h2>

<p>The floor beneath them is a kaleidoscope of pop-art illustrations—guitar strings vibrating with energy, QR codes bridging the physical and digital worlds, and abstract designs that spark the imagination. It's Alice in Wonderland meets contemporary digital art, creating a space that feels both nostalgic and futuristically innovative.</p>

<h2>Nature Meets Technology</h2>

<p>Hanging greenery cascades from above, red flowers add bursts of color, and oversized playing cards—spades and hearts—adorn the white walls, creating that unmistakable immersive environment that Immersia XR is known for. It's where nature meets technology, where the ordinary becomes extraordinary.</p>

<h2>It's Never Too Late</h2>

<p>This installation captures something beautiful: the joy of exploration has no expiration date. These women prove that embracing new technologies, stepping into virtual worlds, and discovering something new isn't just for the young—it's for anyone with a curious spirit.</p>

<p>At Immersia XR, we're not just creating VR experiences. We're creating doors to new worlds that anyone can walk through.</p>

<p><strong>Ready to explore? Visit Immersia XR and step into your own adventure.</strong></p>

<!-- SEO Keywords: VR, Immersive Experience, Virtual Reality, Immersia XR, Pop Art, Technology, Innovation -->
<!-- AI Generated Content for SEO --></p>

<p>#VR #ImmersiveExperience #VirtualReality #ImmersiaXR #PopArt #NeverTooOld #Explore #Innovation #Technology #Art</p>""",
        "status": "draft",
        "categories": ["Immersive Experience"],
        "tags": ["VR", "Immersive Experience", "Virtual Reality", "Immersia XR"]
    }
    
    async with async_playwright() as p:
        browser = await p.chromium.launch(headless=False)
        page = await browser.new_page()
        
        # Login to WordPress
        await page.goto("https://immersiaxr.com/wp-login.php")
        await page.fill("#user_login", "elephantyan")
        await page.fill("#user_pass", "GreatXR*2026")
        await page.click("#wp-submit")
        await page.wait_for_load_state("networkidle")
        
        # Go to Posts > Add New
        await page.goto("https://immersiaxr.com/wp-admin/post-new.php")
        
        # Fill title
        await page.fill(".editor-post-title__input", article["title"])
        
        # Fill content - click in the editor area first
        await page.click(".block-editor__typewriter")
        await page.fill(".block-editor__typewriter", article["content"])
        
        # Set categories (simplified - may need adjustment)
        # This is a simplified version
        
        # Publish
        # await page.click(".editor-post-publish-button")
        
        print("Article filled! Review and publish manually.")
        print("Or uncomment the publish line to auto-publish")
        
        await asyncio.sleep(30)
        await browser.close()

if __name__ == "__main__":
    asyncio.run(post_article())