#!/bin/bash
# Pokemon Discovery - Scraper & Catalog Generator Launcher
# Automatically activates virtual environment and runs the scraper

set -e

cd "$(dirname "$0")"

echo "Pokemon Discovery - Product Scraper & Catalog Generator"
echo "================================================"

# Check if virtual environment exists
if [[ ! -d "venv" ]]; then
    echo "Creating virtual environment..."
    python3 -m venv venv
fi

# Activate virtual environment
source venv/bin/activate

# Check if requirements are installed
if ! python -c "import requests, bs4, barcode, selenium" 2>/dev/null; then
    echo "Installing Python requirements..."
    pip install -r requirements.txt
fi

# Run the main script
python run_scraper.py

echo ""
echo "Script completed. Check the output above for results."