#!/bin/bash

# Test script to verify video processing with all 9 processors

API_KEY="muser_643fae7c05d14cf6bb896940311abb25_1774629545_b9f1a88f"
API_URL="http://localhost:3002"

echo "=== Testing Momentry Core Video Processing ==="
echo "API Key: ${API_KEY:0:20}..."
echo ""

# 1. Check health
echo "1. Checking API health..."
curl -s -X GET "$API_URL/health" -H "X-API-Key: $API_KEY" | jq .
echo ""

# 2. Register a test video (use a short video for testing)
TEST_VIDEO="/Users/accusys/momentry/var/sftpgo/data/demo/ExaSAN PCIe series - Director Ou Yu-Zhi Shares His Experience.mp4"
echo "2. Registering test video: $(basename "$TEST_VIDEO")"
REGISTER_RESPONSE=$(curl -s -X POST "$API_URL/api/v1/register" \
	-H "Content-Type: application/json" \
	-H "X-API-Key: $API_KEY" \
	-d "{\"path\": \"$TEST_VIDEO\"}")

echo "$REGISTER_RESPONSE" | jq .
UUID=$(echo "$REGISTER_RESPONSE" | jq -r '.uuid')
echo "Video UUID: $UUID"
echo ""

# 3. Check progress
echo "3. Checking initial progress..."
sleep 2
curl -s -X GET "$API_URL/api/v1/progress/$UUID" -H "X-API-Key: $API_KEY" | jq .
echo ""

# 4. Check jobs
echo "4. Checking jobs..."
curl -s -X GET "$API_URL/api/v1/jobs" -H "X-API-Key: $API_KEY" | jq .
echo ""

# 5. Monitor worker logs
echo "5. Monitoring worker logs (tail -f)..."
echo "Press Ctrl+C to stop monitoring"
echo ""
tail -f /Users/accusys/momentry/log/momentry_worker.log
