158 lines
4.8 KiB
Python
Executable File
158 lines
4.8 KiB
Python
Executable File
#!/usr/bin/env python3
|
||
"""
|
||
Script de diagnóstico para verificar la obtención de URLs de YouTube
|
||
"""
|
||
|
||
import subprocess
|
||
import sys
|
||
|
||
def test_yt_dlp():
|
||
"""Probar que yt-dlp esté instalado y funcionando"""
|
||
print("=" * 70)
|
||
print("🔍 DIAGNÓSTICO DE YT-DLP Y YOUTUBE")
|
||
print("=" * 70)
|
||
print()
|
||
|
||
# 1. Verificar que yt-dlp esté instalado
|
||
print("1️⃣ Verificando instalación de yt-dlp...")
|
||
try:
|
||
result = subprocess.run(["yt-dlp", "--version"], capture_output=True, text=True, timeout=5)
|
||
if result.returncode == 0:
|
||
print(f" ✅ yt-dlp instalado: {result.stdout.strip()}")
|
||
else:
|
||
print(f" ❌ Error: {result.stderr}")
|
||
return False
|
||
except FileNotFoundError:
|
||
print(" ❌ yt-dlp NO está instalado")
|
||
print(" 💡 Instala con: pip install -U yt-dlp")
|
||
return False
|
||
except Exception as e:
|
||
print(f" ❌ Error: {e}")
|
||
return False
|
||
|
||
print()
|
||
|
||
# 2. Probar con un video de ejemplo
|
||
print("2️⃣ Probando obtención de URL con video de ejemplo...")
|
||
|
||
# Usar un video público conocido (puedes cambiar esto)
|
||
test_url = input(" Ingresa URL de video de YouTube para probar (o ENTER para omitir): ").strip()
|
||
|
||
if not test_url:
|
||
print(" ⏭️ Omitido")
|
||
return True
|
||
|
||
print(f" 📺 Probando: {test_url}")
|
||
print()
|
||
|
||
# 3. Intentar obtener URL
|
||
command = [
|
||
"yt-dlp",
|
||
"-g",
|
||
"-f", "best",
|
||
"--no-warnings",
|
||
test_url
|
||
]
|
||
|
||
print(" 🔄 Ejecutando yt-dlp...")
|
||
try:
|
||
result = subprocess.run(command, capture_output=True, text=True, timeout=60)
|
||
|
||
if result.returncode == 0:
|
||
urls = result.stdout.strip().split('\n')
|
||
print(f" ✅ Éxito! Se obtuvieron {len(urls)} URL(s)")
|
||
print()
|
||
|
||
for i, url in enumerate(urls, 1):
|
||
if url:
|
||
is_m3u8 = 'm3u8' in url.lower()
|
||
is_google = 'googlevideo.com' in url
|
||
|
||
print(f" URL {i}:")
|
||
if is_m3u8:
|
||
print(" 📹 Tipo: m3u8 (HLS)")
|
||
elif is_google:
|
||
print(" 📹 Tipo: Google Video")
|
||
else:
|
||
print(" 📹 Tipo: Otro")
|
||
|
||
print(f" 🔗 {url[:80]}...")
|
||
print()
|
||
|
||
return True
|
||
else:
|
||
print(f" ❌ Error al obtener URL")
|
||
print(f" Código de salida: {result.returncode}")
|
||
if result.stderr:
|
||
print(f" Error: {result.stderr[:300]}")
|
||
|
||
# Sugerencias
|
||
print()
|
||
print(" 💡 Posibles causas:")
|
||
print(" 1. El video no está disponible")
|
||
print(" 2. El video tiene restricciones geográficas")
|
||
print(" 3. El video requiere autenticación")
|
||
print(" 4. YouTube bloqueó temporalmente el acceso")
|
||
print()
|
||
print(" 💡 Soluciones:")
|
||
print(" 1. Intenta con otro video")
|
||
print(" 2. Usa un video EN VIVO (🔴)")
|
||
print(" 3. Agrega cookies.txt de YouTube")
|
||
print(" 4. Actualiza yt-dlp: pip install -U yt-dlp")
|
||
|
||
return False
|
||
|
||
except subprocess.TimeoutExpired:
|
||
print(" ⏱️ Timeout: La operación tardó más de 60 segundos")
|
||
return False
|
||
except Exception as e:
|
||
print(f" ❌ Error: {e}")
|
||
return False
|
||
|
||
def test_ffmpeg():
|
||
"""Verificar que FFmpeg esté instalado"""
|
||
print()
|
||
print("3️⃣ Verificando FFmpeg...")
|
||
try:
|
||
result = subprocess.run(["ffmpeg", "-version"], capture_output=True, text=True, timeout=5)
|
||
if result.returncode == 0:
|
||
version_line = result.stdout.split('\n')[0]
|
||
print(f" ✅ FFmpeg instalado: {version_line}")
|
||
return True
|
||
else:
|
||
print(" ❌ FFmpeg no responde correctamente")
|
||
return False
|
||
except FileNotFoundError:
|
||
print(" ❌ FFmpeg NO está instalado")
|
||
print(" 💡 Instala con: brew install ffmpeg (macOS) o apt install ffmpeg (Linux)")
|
||
return False
|
||
except Exception as e:
|
||
print(f" ❌ Error: {e}")
|
||
return False
|
||
|
||
def main():
|
||
print()
|
||
|
||
yt_dlp_ok = test_yt_dlp()
|
||
ffmpeg_ok = test_ffmpeg()
|
||
|
||
print()
|
||
print("=" * 70)
|
||
print("📊 RESUMEN")
|
||
print("=" * 70)
|
||
|
||
if yt_dlp_ok and ffmpeg_ok:
|
||
print("✅ Todo está listo para transmitir!")
|
||
else:
|
||
print("⚠️ Hay problemas que necesitan atención:")
|
||
if not yt_dlp_ok:
|
||
print(" ❌ yt-dlp tiene problemas")
|
||
if not ffmpeg_ok:
|
||
print(" ❌ FFmpeg no está disponible")
|
||
|
||
print("=" * 70)
|
||
print()
|
||
|
||
if __name__ == "__main__":
|
||
main()
|