#!/bin/bash

# Agenda Informe Scraper - ZERO EXTERNAL DEPENDENCIES (native Python only)

echo ""
echo "Agenda Informe Scraper"
echo "======================"
echo ""

# Get script directory
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd "$SCRIPT_DIR"

# Detect Python
PYTHON3=""
if command -v python3 &> /dev/null; then
    PYTHON3="python3"
elif command -v python &> /dev/null; then
    PYTHON3="python"
else
    echo "❌ ERROR: Python 3.7+ not found. Install it and try again."
    exit 1
fi

# No dependencies needed - uses only native Python!
echo "[1] Using native Python (no external packages needed)"

# Run scraper
echo "[2] Scraping events..."
echo ""

$PYTHON3 agenda_simple.py
EXIT_CODE=$?

# Done or error
echo ""
if [ $EXIT_CODE -eq 0 ]; then
    echo "[3] Files generated:"
    echo "    - calendar.ics      (your calendar file)"
    echo "    - events_cache.json (backup)"
    echo ""
    echo "✅ Done!"
else
    echo "❌ Script failed with exit code $EXIT_CODE"
    exit 1
fi
echo ""
