#!/bin/bash # Auto-download missing catalogue icons from Habbo CDN # Usage: ./download-missing-icons.sh ASSET_DIR="/Users/matt/DEV/retro/nitro-assets/nitro-assets/c_images/catalogue" LOG_FILE="/tmp/asset-server.log" echo "🔍 Scanning asset server log for missing catalogue icons..." # Extract unique missing icon IDs from recent 404 errors MISSING_IDS=$(tail -500 "$LOG_FILE" | grep "catalogue/icon_" | grep "404" | sed 's/.*icon_//' | sed 's/.png.*//' | sort -u) if [ -z "$MISSING_IDS" ]; then echo "✅ No missing icons found in recent requests!" exit 0 fi echo "📥 Found $(echo "$MISSING_IDS" | wc -l) missing icon IDs" echo "" cd "$ASSET_DIR" || exit 1 DOWNLOADED=0 FAILED=0 for ID in $MISSING_IDS; do if [ ! -f "icon_${ID}.png" ]; then echo -n "Downloading icon_${ID}.png... " if curl -s -f -o "icon_${ID}.png" "https://images.habbo.com/c_images/catalogue/icon_${ID}.png"; then if [ -s "icon_${ID}.png" ]; then echo "✓" ((DOWNLOADED++)) else echo "✗ (empty file)" rm -f "icon_${ID}.png" ((FAILED++)) fi else echo "✗ (not found on CDN)" rm -f "icon_${ID}.png" ((FAILED++)) fi else echo "⊙ icon_${ID}.png already exists" fi done echo "" echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" echo "📊 Summary:" echo " Downloaded: $DOWNLOADED" echo " Failed: $FAILED" echo " Total icons now: $(ls -1 icon_*.png 2>/dev/null | wc -l)" echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"