99 lines
2.9 KiB
Bash
Executable File
99 lines
2.9 KiB
Bash
Executable File
#!/bin/bash
|
||
#
|
||
# Hanasuba Music Service v2.0 - Setup Script
|
||
#
|
||
|
||
set -e
|
||
|
||
echo "╔══════════════════════════════════════════════════╗"
|
||
echo "║ 🎵 Hanasuba Music Service v2.0 Setup ║"
|
||
echo "╚══════════════════════════════════════════════════╝"
|
||
echo ""
|
||
|
||
# Check prerequisites
|
||
echo "🔍 Checking prerequisites..."
|
||
|
||
if ! command -v node &> /dev/null; then
|
||
echo "❌ Node.js not found. Please install Node.js 18+"
|
||
exit 1
|
||
fi
|
||
|
||
if ! command -v python3 &> /dev/null; then
|
||
echo "❌ Python 3 not found. Please install Python 3.9+"
|
||
exit 1
|
||
fi
|
||
|
||
if ! command -v yt-dlp &> /dev/null; then
|
||
echo "⚠️ yt-dlp not found. Installing..."
|
||
pip3 install yt-dlp
|
||
fi
|
||
|
||
if ! command -v ffmpeg &> /dev/null; then
|
||
echo "❌ ffmpeg not found. Please install ffmpeg"
|
||
echo " sudo apt install ffmpeg # Debian/Ubuntu"
|
||
exit 1
|
||
fi
|
||
|
||
echo "✅ Prerequisites OK"
|
||
echo ""
|
||
|
||
# Install Node dependencies
|
||
echo "📦 Installing Node.js dependencies..."
|
||
npm install
|
||
echo "✅ Node.js dependencies installed"
|
||
echo ""
|
||
|
||
# Install Python dependencies
|
||
echo "🐍 Installing Python dependencies..."
|
||
pip3 install -r requirements.txt
|
||
echo "✅ Python dependencies installed"
|
||
echo ""
|
||
|
||
# Install Playwright browsers
|
||
echo "🎭 Installing Playwright Firefox..."
|
||
python3 -m playwright install firefox
|
||
echo "✅ Playwright Firefox installed"
|
||
echo ""
|
||
|
||
# Create output directory
|
||
echo "📁 Creating output directory..."
|
||
mkdir -p output
|
||
chmod 755 output
|
||
echo "✅ Output directory created"
|
||
echo ""
|
||
|
||
# Setup .env if not exists
|
||
if [ ! -f .env ]; then
|
||
echo "⚙️ Creating .env file..."
|
||
cp .env.example .env
|
||
echo "✅ .env created (please edit if needed)"
|
||
else
|
||
echo "ℹ️ .env already exists (skipping)"
|
||
fi
|
||
echo ""
|
||
|
||
# Extract initial cookies
|
||
echo "🍪 Extracting YouTube cookies (this may take 30s)..."
|
||
if python3 src/python/extract_cookies.py; then
|
||
echo "✅ Cookies extracted successfully"
|
||
else
|
||
echo "⚠️ Cookie extraction failed (you can retry later with: npm run cookies:extract)"
|
||
fi
|
||
echo ""
|
||
|
||
echo "╔══════════════════════════════════════════════════╗"
|
||
echo "║ ✅ Setup Complete! ║"
|
||
echo "╚══════════════════════════════════════════════════╝"
|
||
echo ""
|
||
echo "🚀 Start the service:"
|
||
echo " npm start"
|
||
echo ""
|
||
echo "📖 Read the docs:"
|
||
echo " cat README.md"
|
||
echo ""
|
||
echo "🧪 Test download:"
|
||
echo " curl -X POST http://localhost:8889/download \\"
|
||
echo " -H 'Content-Type: application/json' \\"
|
||
echo " -d '{\"url\": \"https://youtube.com/watch?v=dQw4w9WgXcQ\"}'"
|
||
echo ""
|