TubeScript-API/fix-ytdlp.sh
2026-01-29 22:49:00 -07:00

133 lines
4.0 KiB
Bash
Executable File
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
# Script para forzar reinstalación de yt-dlp en contenedores
echo "═══════════════════════════════════════════════════════════"
echo " 🔧 Reinstalación Forzada de yt-dlp"
echo "═══════════════════════════════════════════════════════════"
echo ""
# Colores
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
RED='\033[0;31m'
NC='\033[0m'
print_success() {
echo -e "${GREEN}$1${NC}"
}
print_error() {
echo -e "${RED}$1${NC}"
}
print_info() {
echo -e "${YELLOW} $1${NC}"
}
# Verificar Docker
if ! command -v docker &> /dev/null; then
print_error "Docker no está instalado"
exit 1
fi
# Verificar contenedores
echo "🔍 Verificando contenedores..."
if ! docker ps | grep -q streamlit_panel; then
print_error "El contenedor streamlit_panel no está corriendo"
print_info "Inicia con: docker-compose up -d"
exit 1
fi
if ! docker ps | grep -q tubescript_api; then
print_error "El contenedor tubescript_api no está corriendo"
print_info "Inicia con: docker-compose up -d"
exit 1
fi
print_success "Contenedores encontrados"
echo ""
# Desinstalar yt-dlp actual
echo "🗑️ Desinstalando yt-dlp antiguo en streamlit_panel..."
docker exec streamlit_panel pip uninstall -y yt-dlp 2>/dev/null
docker exec streamlit_panel pip uninstall -y yt_dlp 2>/dev/null
echo "🗑️ Desinstalando yt-dlp antiguo en tubescript_api..."
docker exec tubescript_api pip uninstall -y yt-dlp 2>/dev/null
docker exec tubescript_api pip uninstall -y yt_dlp 2>/dev/null
echo ""
# Limpiar cache de pip
echo "🧹 Limpiando cache de pip..."
docker exec streamlit_panel pip cache purge 2>/dev/null
docker exec tubescript_api pip cache purge 2>/dev/null
echo ""
# Reinstalar yt-dlp desde cero
echo "📦 Reinstalando yt-dlp en streamlit_panel..."
docker exec streamlit_panel pip install --no-cache-dir --force-reinstall yt-dlp
if [ $? -eq 0 ]; then
print_success "yt-dlp reinstalado en streamlit_panel"
# Verificar versión
version=$(docker exec streamlit_panel python3 -c "import yt_dlp; print(yt_dlp.version.__version__)" 2>/dev/null)
if [ ! -z "$version" ]; then
print_info "Versión instalada: $version"
fi
else
print_error "Error al reinstalar yt-dlp en streamlit_panel"
fi
echo ""
echo "📦 Reinstalando yt-dlp en tubescript_api..."
docker exec tubescript_api pip install --no-cache-dir --force-reinstall yt-dlp
if [ $? -eq 0 ]; then
print_success "yt-dlp reinstalado en tubescript_api"
# Verificar versión
version=$(docker exec tubescript_api python3 -c "import yt_dlp; print(yt_dlp.version.__version__)" 2>/dev/null)
if [ ! -z "$version" ]; then
print_info "Versión instalada: $version"
fi
else
print_error "Error al reinstalar yt-dlp en tubescript_api"
fi
echo ""
# Verificar instalación
echo "🔍 Verificando instalación..."
echo ""
echo "Streamlit Panel:"
docker exec streamlit_panel yt-dlp --version 2>&1 | head -1
echo ""
echo "Tubescript API:"
docker exec tubescript_api yt-dlp --version 2>&1 | head -1
echo ""
# Reiniciar contenedores
echo "🔄 Reiniciando contenedores para aplicar cambios..."
docker-compose restart streamlit-panel tubescript-api
echo ""
echo "═══════════════════════════════════════════════════════════"
print_success "Reinstalación completada"
echo "═══════════════════════════════════════════════════════════"
echo ""
print_info "Ahora puedes probar con un video en vivo en:"
echo " http://localhost:8501"
echo ""
print_info "Si el error persiste, ejecuta:"
echo " docker-compose down"
echo " docker-compose build --no-cache"
echo " docker-compose up -d"
echo ""