import datetime

# Configuration du domaine
DOMAIN = "https://turismo.cl"

# Liste des destinations stratégiques pour le SEO au Chili
destinations = [
    "atacama", "patagonia", "valparaiso", "santiago", 
    "isla-de-pascua", "puerto-varas", "torres-del-paine",
    "valle-del-elqui", "chiloe", "pichilemu"
]

def generate_sitemap():
    now = datetime.datetime.now().strftime("%Y-%m-%d")
    
    sitemap_content = '<?xml version="1.0" encoding="UTF-8"?>\n'
    sitemap_content += '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">\n'

    # 1. URL Racine
    sitemap_content += f'''  <url>
    <loc>{DOMAIN}/</loc>
    <lastmod>{now}</lastmod>
    <changefreq>daily</changefreq>
    <priority>1.0</priority>
  </url>\n'''

    # 2. URLs des Destinations (Dynamiques pour l'indexation)
    for dest in destinations:
        sitemap_content += f'''  <url>
    <loc>{DOMAIN}/explore/{dest}</loc>
    <lastmod>{now}</lastmod>
    <changefreq>weekly</changefreq>
    <priority>0.8</priority>
  </url>\n'''

    sitemap_content += '  <url>
    <loc>https://www.turismo.cl/los_lagos/chiloe.html</loc>
    <lastmod>2026-03-23</lastmod>
    <changefreq>weekly</changefreq>
  </url>
  <url>
    <loc>https://www.turismo.cl/libertador_general_bernardo_ohiggins/pichilemu.html</loc>
    <lastmod>2026-03-23</lastmod>
    <changefreq>weekly</changefreq>
  </url>
  <url>
    <loc>https://www.turismo.cl/antofagasta/san_pedro_de_atacama.html</loc>
    <lastmod>2026-03-23</lastmod>
    <changefreq>weekly</changefreq>
  </url>
  <url>
    <loc>https://www.turismo.cl/los_lagos/puerto_varas.html</loc>
    <lastmod>2026-03-23</lastmod>
    <changefreq>weekly</changefreq>
  </url>
</urlset>'

    # Écriture du fichier
    with open("sitemap.xml", "w", encoding="utf-8") as f:
        f.write(sitemap_content)
    
    print("Succès : sitemap.xml généré pour Turismo.cl")

if __name__ == "__main__":
    generate_sitemap()
