✨ Añadir detección automática de FFmpeg
- Agregar funciones check_ffmpeg() y install_ffmpeg() para detectar e instalar FFmpeg - Implementar verificación previa a descargas MP3 para asegurar disponibilidad de FFmpeg - Crear endpoints /api/ffmpeg/status y /api/ffmpeg/install para gestión de FFmpeg - Mejorar frontend con detección de estado de FFmpeg y opción de instalación automática - Deshabilitar opción MP3 si FFmpeg no está disponible - Añadir mensajes de error específicos para problemas de FFmpeg 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -3,6 +3,7 @@ let progressInterval = null;
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
loadDownloads();
|
||||
checkFFmpegStatus();
|
||||
|
||||
document.getElementById('downloadForm').addEventListener('submit', function(e) {
|
||||
e.preventDefault();
|
||||
@@ -265,5 +266,81 @@ function formatFileSize(bytes) {
|
||||
return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i];
|
||||
}
|
||||
|
||||
function checkFFmpegStatus() {
|
||||
fetch('/api/ffmpeg/status')
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
const mp3Option = document.querySelector('input[value="mp3"]');
|
||||
const mp3Label = document.querySelector('label[for="mp3"]');
|
||||
|
||||
if (!data.available) {
|
||||
// MP3 option is not available
|
||||
mp3Option.disabled = true;
|
||||
mp3Label.style.opacity = '0.5';
|
||||
mp3Label.style.cursor = 'not-allowed';
|
||||
|
||||
// Add warning indicator
|
||||
if (!document.getElementById('ffmpegWarning')) {
|
||||
const warning = document.createElement('div');
|
||||
warning.id = 'ffmpegWarning';
|
||||
warning.className = 'alert alert-warning alert-sm mt-2';
|
||||
warning.innerHTML = `
|
||||
<i class="fas fa-exclamation-triangle"></i>
|
||||
FFmpeg no está disponible. Las descargas de MP3 requieren FFmpeg.
|
||||
<button class="btn btn-sm btn-outline-warning ms-2" onclick="installFFmpeg()">
|
||||
<i class="fas fa-download"></i> Instalar FFmpeg
|
||||
</button>
|
||||
`;
|
||||
mp3Label.parentNode.insertBefore(warning, mp3Label.parentNode.nextSibling);
|
||||
|
||||
// Switch to MP4 by default
|
||||
document.querySelector('input[value="mp4"]').checked = true;
|
||||
}
|
||||
} else {
|
||||
// FFmpeg is available
|
||||
if (document.getElementById('ffmpegWarning')) {
|
||||
document.getElementById('ffmpegWarning').remove();
|
||||
}
|
||||
mp3Option.disabled = false;
|
||||
mp3Label.style.opacity = '1';
|
||||
mp3Label.style.cursor = 'pointer';
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('Error checking FFmpeg status:', error);
|
||||
});
|
||||
}
|
||||
|
||||
function installFFmpeg() {
|
||||
const btn = document.querySelector('#ffmpegWarning button');
|
||||
const originalContent = btn.innerHTML;
|
||||
btn.disabled = true;
|
||||
btn.innerHTML = '<i class="fas fa-spinner fa-spin"></i> Instalando...';
|
||||
|
||||
fetch('/api/ffmpeg/install', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
}
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if (data.success) {
|
||||
alert('✅ ' + data.message);
|
||||
checkFFmpegStatus(); // Recheck status
|
||||
} else {
|
||||
alert('❌ ' + data.message);
|
||||
btn.disabled = false;
|
||||
btn.innerHTML = originalContent;
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('Error installing FFmpeg:', error);
|
||||
alert('Error al intentar instalar FFmpeg: ' + error.message);
|
||||
btn.disabled = false;
|
||||
btn.innerHTML = originalContent;
|
||||
});
|
||||
}
|
||||
|
||||
// Auto-refresh downloads list every 30 seconds
|
||||
setInterval(loadDownloads, 30000);
|
||||
Reference in New Issue
Block a user