87 lines
3.0 KiB
JavaScript
87 lines
3.0 KiB
JavaScript
#!/usr/bin/env node
|
|
|
|
import { execSync } from 'child_process';
|
|
import { existsSync, writeFileSync } from 'fs';
|
|
import { join } from 'path';
|
|
import { fileURLToPath } from 'url';
|
|
import { dirname } from 'path';
|
|
|
|
const __filename = fileURLToPath(import.meta.url);
|
|
const __dirname = dirname(__filename);
|
|
|
|
console.log('🚀 YouTube Downloader - Installation\n');
|
|
|
|
// Prüfe Node.js Version
|
|
const nodeVersion = process.version;
|
|
const majorVersion = parseInt(nodeVersion.slice(1).split('.')[0]);
|
|
if (majorVersion < 20) {
|
|
console.error('❌ Node.js Version 20 oder höher ist erforderlich.');
|
|
console.error(` Aktuelle Version: ${nodeVersion}`);
|
|
process.exit(1);
|
|
}
|
|
console.log(`✅ Node.js Version: ${nodeVersion}\n`);
|
|
|
|
// Schritt 1: npm install
|
|
console.log('📦 Installiere Dependencies...');
|
|
try {
|
|
execSync('npm install', { stdio: 'inherit', cwd: __dirname });
|
|
console.log('✅ Dependencies installiert\n');
|
|
} catch (error) {
|
|
console.error('❌ Fehler beim Installieren der Dependencies');
|
|
process.exit(1);
|
|
}
|
|
|
|
// Schritt 2: Prüfe yt-dlp
|
|
console.log('🔍 Prüfe yt-dlp Installation...');
|
|
let ytdlpInstalled = false;
|
|
try {
|
|
execSync('yt-dlp --version', { stdio: 'ignore' });
|
|
ytdlpInstalled = true;
|
|
console.log('✅ yt-dlp ist bereits installiert\n');
|
|
} catch (error) {
|
|
console.log('⚠️ yt-dlp ist nicht installiert');
|
|
console.log('\n📥 Bitte installiere yt-dlp:');
|
|
console.log(' macOS: brew install yt-dlp');
|
|
console.log(' Linux: sudo apt-get install yt-dlp');
|
|
console.log(' Windows: pip install yt-dlp');
|
|
console.log(' Oder: pip install yt-dlp (funktioniert auf allen Plattformen)\n');
|
|
}
|
|
|
|
// Schritt 3: Erstelle .env Datei falls nicht vorhanden
|
|
const envPath = join(__dirname, '.env');
|
|
if (!existsSync(envPath)) {
|
|
console.log('📝 Erstelle .env Datei...');
|
|
const envContent = `LOGIN_USERNAME=admin
|
|
LOGIN_PASSWORD=change-me-in-production
|
|
DOWNLOAD_DIR=./downloaded
|
|
SESSION_SECRET=change-me-in-production-$(Date.now())
|
|
`;
|
|
writeFileSync(envPath, envContent);
|
|
console.log('✅ .env Datei erstellt');
|
|
console.log('⚠️ WICHTIG: Bitte ändere LOGIN_PASSWORD und SESSION_SECRET in der .env Datei!\n');
|
|
} else {
|
|
console.log('✅ .env Datei existiert bereits\n');
|
|
}
|
|
|
|
// Schritt 4: Erstelle downloaded Verzeichnis
|
|
const downloadDir = join(__dirname, 'downloaded');
|
|
if (!existsSync(downloadDir)) {
|
|
console.log('📁 Erstelle Download-Verzeichnis...');
|
|
execSync(`mkdir -p "${downloadDir}"`, { cwd: __dirname });
|
|
console.log('✅ Download-Verzeichnis erstellt\n');
|
|
} else {
|
|
console.log('✅ Download-Verzeichnis existiert bereits\n');
|
|
}
|
|
|
|
console.log('✨ Installation abgeschlossen!\n');
|
|
console.log('📋 Nächste Schritte:');
|
|
console.log(' 1. Bearbeite die .env Datei und setze LOGIN_PASSWORD und SESSION_SECRET');
|
|
if (!ytdlpInstalled) {
|
|
console.log(' 2. Installiere yt-dlp (siehe Anweisungen oben)');
|
|
console.log(' 3. Starte die Anwendung mit: npm run dev');
|
|
} else {
|
|
console.log(' 2. Starte die Anwendung mit: npm run dev');
|
|
}
|
|
console.log(' 4. Öffne http://localhost:4321 im Browser\n');
|
|
|