TubeScript-API/COMANDOS_RAPIDOS.sh

376 lines
12 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.

#!/bin/bash
# ============================================================
# TubeScript API - COMANDOS RÁPIDOS
# ============================================================
# Usa este archivo como referencia rápida de comandos
# Copia y pega los comandos que necesites
echo "📚 TubeScript API - Comandos Rápidos"
echo ""
# ============================================================
# 🚀 INICIO RÁPIDO
# ============================================================
cat << 'EOF'
🚀 INICIO RÁPIDO (3 pasos):
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
1⃣ Crear red:
./docker-create-network.sh
2⃣ Iniciar servicios:
./docker-manager.sh
# O:
docker-compose up -d
3⃣ Acceder:
Panel: http://localhost:8501
API: http://localhost:8080/docs
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🎛️ GESTIÓN DE SERVICIOS
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
📍 Gestor Interactivo (Recomendado):
./docker-manager.sh
📍 Iniciar TODO:
docker-compose up -d
📍 Iniciar SOLO API:
./docker-start-api.sh
📍 Iniciar SOLO Streamlit:
./docker-start-streamlit.sh
📍 Detener TODO:
./docker-stop-all.sh
# O:
docker-compose down
📍 Reiniciar TODO:
docker-compose restart
📍 Ver Estado:
docker ps
docker ps -a # Incluir detenidos
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
📋 LOGS Y MONITOREO
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
📍 Ver Logs API:
docker logs -f tubescript_api
# O:
./docker-logs-separate.sh api
📍 Ver Logs Streamlit:
docker logs -f streamlit_panel
# O:
./docker-logs-separate.sh streamlit
📍 Ver Logs AMBOS:
docker-compose logs -f
# O:
./docker-logs-separate.sh both
📍 Ver últimas 100 líneas:
docker logs --tail 100 tubescript_api
docker logs --tail 100 streamlit_panel
📍 Ver recursos (CPU/RAM):
docker stats
# O solo TubeScript:
docker stats tubescript_api streamlit_panel
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🔄 ACTUALIZACIÓN Y MANTENIMIENTO
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
📍 Actualizar yt-dlp:
docker exec tubescript_api pip install --upgrade yt-dlp
docker exec streamlit_panel pip install --upgrade yt-dlp
📍 Reconstruir Contenedores:
docker-compose down
docker-compose build --no-cache
docker-compose up -d
📍 Actualizar código (con Git):
git pull
docker-compose down
docker-compose build
docker-compose up -d
📍 Limpiar contenedores viejos:
docker container prune -f
📍 Limpiar imágenes viejas:
docker image prune -a -f
📍 Limpiar TODO (⚠️ cuidado):
docker system prune -a --volumes
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🐛 DEBUGGING Y SOLUCIÓN DE PROBLEMAS
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
📍 Entrar al contenedor (shell):
docker exec -it tubescript_api /bin/bash
docker exec -it streamlit_panel /bin/bash
📍 Verificar versión yt-dlp:
docker exec tubescript_api yt-dlp --version
docker exec streamlit_panel yt-dlp --version
📍 Probar endpoint manualmente:
curl http://localhost:8080/stream/G01-33V6I2g
📍 Ver error completo:
docker logs tubescript_api 2>&1 | tail -50
docker logs streamlit_panel 2>&1 | tail -50
📍 Reiniciar un servicio:
docker restart tubescript_api
docker restart streamlit_panel
📍 Ver qué usa un puerto:
lsof -i :8080 # API
lsof -i :8501 # Streamlit
📍 Matar proceso en un puerto (macOS/Linux):
kill -9 $(lsof -ti:8080)
kill -9 $(lsof -ti:8501)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🌐 ACCESO Y URLs
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
📍 Panel Web:
http://localhost:8501
📍 API FastAPI:
http://localhost:8080
📍 API Docs (Swagger):
http://localhost:8080/docs
📍 API ReDoc:
http://localhost:8080/redoc
📍 Abrir en navegador (macOS):
open http://localhost:8501
open http://localhost:8080/docs
📍 Abrir en navegador (Linux):
xdg-open http://localhost:8501
xdg-open http://localhost:8080/docs
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
⚙️ CONFIGURACIÓN
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
📍 Crear/Editar .env:
cp .env.example .env
nano .env
# O:
vim .env
📍 Ver configuración actual:
cat stream_config.json | python3 -m json.tool
📍 Ver procesos activos:
cat process_state.json | python3 -m json.tool
📍 Reiniciar después de cambiar .env:
docker-compose down
docker-compose up -d
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🧪 TESTING Y PRUEBAS
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
📍 Probar obtener stream:
curl -X GET "http://localhost:8080/stream/G01-33V6I2g" | jq
📍 Probar obtener transcripción:
curl -X GET "http://localhost:8080/transcript/WODSeZfCnUg?lang=es" | jq
📍 Probar con HTTPie:
http GET localhost:8080/stream/G01-33V6I2g
📍 Extraer solo la URL del stream:
curl -s http://localhost:8080/stream/G01-33V6I2g | jq -r '.stream_url'
📍 Test completo de transmisión:
# 1. Obtener URL
STREAM_URL=$(curl -s http://localhost:8080/stream/G01-33V6I2g | jq -r '.stream_url')
# 2. Transmitir (test de 10 segundos)
timeout 10 ffmpeg -re -i "$STREAM_URL" -c copy -f flv rtmp://test/key
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
📊 INFORMACIÓN DEL SISTEMA
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
📍 Ver información de contenedores:
docker inspect tubescript_api
docker inspect streamlit_panel
📍 Ver red de Docker:
docker network inspect tubescript-network
📍 Ver volúmenes:
docker volume ls
📍 Ver tamaño de imágenes:
docker images | grep tubescript
📍 Ver uso de disco de Docker:
docker system df
📍 Ver procesos dentro del contenedor:
docker top tubescript_api
docker top streamlit_panel
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🔐 SEGURIDAD Y PERMISOS
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
📍 Dar permisos a scripts:
chmod +x *.sh
📍 Ver permisos actuales:
ls -la *.sh
📍 Cambiar permisos de archivos de config:
chmod 600 stream_config.json
chmod 600 cookies.txt
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🎯 COMANDOS DE PRODUCCIÓN
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
📍 Iniciar en segundo plano:
docker-compose up -d
📍 Ver estado de salud:
docker ps --format "table {{.Names}}\t{{.Status}}\t{{.Ports}}"
📍 Reinicio automático (ya configurado):
# En docker-compose.yml:
restart: unless-stopped
📍 Backup de configuración:
tar -czf backup_$(date +%Y%m%d).tar.gz \
stream_config.json \
process_state.json \
streams_state.json \
cookies.txt \
.env
📍 Restaurar backup:
tar -xzf backup_20260130.tar.gz
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
💡 TIPS Y TRUCOS
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
📍 Alias útiles (agregar a ~/.zshrc o ~/.bashrc):
alias ts-start='docker-compose up -d'
alias ts-stop='docker-compose down'
alias ts-logs='docker-compose logs -f'
alias ts-restart='docker-compose restart'
alias ts-panel='open http://localhost:8501'
alias ts-api='open http://localhost:8080/docs'
📍 Ver logs con colores (si tienes grc):
grc docker logs -f tubescript_api
📍 Buscar en logs:
docker logs tubescript_api 2>&1 | grep "ERROR"
docker logs streamlit_panel 2>&1 | grep "stream"
📍 Seguir solo errores:
docker logs -f tubescript_api 2>&1 | grep -i error
📍 Contar líneas de log:
docker logs tubescript_api 2>&1 | wc -l
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
📚 DOCUMENTACIÓN
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
📍 Ver documentación disponible:
ls -1 *.md
📍 Abrir documentación:
QUICKSTART_COMPLETO.md # Inicio rápido
PANEL_STREAMLIT_GUIA.md # Guía del panel
DOCKER_COMANDOS_SEPARADOS_COMPLETO.md # Comandos Docker
API_EXAMPLES.md # Ejemplos de API
RESUMEN_IMPLEMENTACION.md # Resumen completo
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🆘 AYUDA RÁPIDA
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
❌ PROBLEMA: "No se pudo obtener URL del stream"
✅ SOLUCIÓN:
docker exec streamlit_panel pip install --upgrade yt-dlp
# O reconstruir:
docker-compose down && docker-compose build --no-cache && docker-compose up -d
❌ PROBLEMA: "Puerto ya en uso"
✅ SOLUCIÓN:
lsof -i :8080 # Ver qué lo usa
# Cambiar puerto en docker-compose.yml o matar proceso
❌ PROBLEMA: "Error al descargar subtítulos"
✅ SOLUCIÓN:
# El video puede no tener subtítulos
# Prueba con otro video
❌ PROBLEMA: "Contenedor se detiene"
✅ SOLUCIÓN:
docker logs tubescript_api
docker logs streamlit_panel
# Ver el error específico
❌ PROBLEMA: "Network not found"
✅ SOLUCIÓN:
./docker-create-network.sh
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✨ Para ayuda interactiva, ejecuta:
./docker-manager.sh
📖 Para documentación completa:
cat QUICKSTART_COMPLETO.md
🌐 Para acceder al panel:
open http://localhost:8501
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
TubeScript API Pro © 2026
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
EOF