92 lines
3.2 KiB
Bash
Executable File
92 lines
3.2 KiB
Bash
Executable File
#!/bin/bash
|
|
# ─────────────────────────────────────────────────────────────
|
|
# YouTube Summarizer — Double-click this file to launch!
|
|
# ─────────────────────────────────────────────────────────────
|
|
|
|
# Move to the folder where this script lives (the project folder)
|
|
cd "$(dirname "$0")"
|
|
|
|
clear
|
|
echo "============================================"
|
|
echo " YouTube Summarizer — Starting up..."
|
|
echo "============================================"
|
|
echo ""
|
|
|
|
# ── Check for Node.js ────────────────────────────────────────
|
|
if ! command -v node &> /dev/null; then
|
|
echo "ERROR: Node.js is not installed."
|
|
echo ""
|
|
echo "To install it, open Terminal and run:"
|
|
echo " brew install node"
|
|
echo ""
|
|
echo "(If you don't have Homebrew, install it first:"
|
|
echo " /bin/bash -c \"\$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)\""
|
|
echo ")"
|
|
echo ""
|
|
echo "Press any key to close..."
|
|
read -n 1
|
|
exit 1
|
|
fi
|
|
|
|
# ── Check for yt-dlp ─────────────────────────────────────────
|
|
if ! command -v yt-dlp &> /dev/null; then
|
|
echo "yt-dlp not found. Installing via Homebrew..."
|
|
if command -v brew &> /dev/null; then
|
|
brew install yt-dlp
|
|
else
|
|
echo "ERROR: yt-dlp is not installed and Homebrew is not available."
|
|
echo "Install yt-dlp manually: https://github.com/yt-dlp/yt-dlp"
|
|
echo ""
|
|
echo "Press any key to close..."
|
|
read -n 1
|
|
exit 1
|
|
fi
|
|
fi
|
|
|
|
# ── Install npm dependencies if needed ───────────────────────
|
|
if [ ! -d "server/node_modules" ]; then
|
|
echo "First run — installing dependencies..."
|
|
cd server
|
|
npm install
|
|
cd ..
|
|
echo ""
|
|
fi
|
|
|
|
# ── Start the server ─────────────────────────────────────────
|
|
echo "Starting server..."
|
|
echo ""
|
|
|
|
# Start server in the background
|
|
cd server
|
|
node index.js &
|
|
SERVER_PID=$!
|
|
cd ..
|
|
|
|
# Wait for server to be ready
|
|
echo "Waiting for server to start..."
|
|
for i in {1..20}; do
|
|
if curl -s http://localhost:3001/api/health > /dev/null 2>&1; then
|
|
break
|
|
fi
|
|
sleep 0.5
|
|
done
|
|
|
|
# ── Open browser ─────────────────────────────────────────────
|
|
echo ""
|
|
echo "Opening browser..."
|
|
open http://localhost:3001
|
|
echo ""
|
|
echo "============================================"
|
|
echo " App is running at http://localhost:3001"
|
|
echo "============================================"
|
|
echo ""
|
|
echo "Leave this window open while using the app."
|
|
echo "To stop the server, close this window or press Ctrl+C."
|
|
echo ""
|
|
|
|
# Keep the script running so the server stays alive
|
|
# When user closes the terminal window or presses Ctrl+C, clean up
|
|
trap "echo ''; echo 'Shutting down server...'; kill $SERVER_PID 2>/dev/null; exit 0" INT TERM
|
|
|
|
wait $SERVER_PID
|