174 lines
3.7 KiB
Markdown
174 lines
3.7 KiB
Markdown
# 🚀 INICIO RÁPIDO: Obtener Transcripts de YouTube
|
||
|
||
## ⚡ Método Más Rápido (30 segundos)
|
||
|
||
### Usando cookies de Chrome directamente:
|
||
|
||
```bash
|
||
# 1. Asegúrate de estar logueado en YouTube en Chrome
|
||
# 2. Ejecuta este comando:
|
||
|
||
yt-dlp --cookies-from-browser chrome --skip-download --write-auto-sub \
|
||
--sub-lang es --sub-format vtt -o "%(id)s.%(ext)s" \
|
||
"https://www.youtube.com/watch?v=K08TM4OVLyo"
|
||
|
||
# 3. Listo! Verás el archivo: K08TM4OVLyo.es.vtt
|
||
```
|
||
|
||
---
|
||
|
||
## 🎯 3 Formas de Obtener Transcripts
|
||
|
||
### 1️⃣ Script Bash (Recomendado - MÁS FÁCIL)
|
||
```bash
|
||
./get_transcript_chrome.sh VIDEO_ID
|
||
```
|
||
|
||
**Ventajas**:
|
||
- ✅ Genera VTT + TXT automáticamente
|
||
- ✅ Muestra preview del contenido
|
||
- ✅ Maneja múltiples perfiles de Chrome
|
||
|
||
### 2️⃣ Script Python
|
||
```bash
|
||
python3 fetch_transcript.py VIDEO_ID es chrome
|
||
```
|
||
|
||
**Ventajas**:
|
||
- ✅ Genera JSON + TXT
|
||
- ✅ Integrado con el proyecto
|
||
- ✅ Maneja formatos automáticamente
|
||
|
||
### 3️⃣ Comando directo yt-dlp
|
||
```bash
|
||
yt-dlp --cookies-from-browser chrome \
|
||
--skip-download --write-auto-sub \
|
||
--sub-lang es --sub-format vtt \
|
||
-o "%(id)s.%(ext)s" \
|
||
"https://www.youtube.com/watch?v=VIDEO_ID"
|
||
```
|
||
|
||
**Ventajas**:
|
||
- ✅ Control total
|
||
- ✅ Personalizable
|
||
- ✅ Para usuarios avanzados
|
||
|
||
---
|
||
|
||
## 🔑 Usar Perfil Específico de Chrome
|
||
|
||
### Ver perfiles disponibles:
|
||
```bash
|
||
# macOS
|
||
ls ~/Library/Application\ Support/Google/Chrome/
|
||
|
||
# Verás algo como:
|
||
# Default
|
||
# Profile 1
|
||
# Profile 2
|
||
```
|
||
|
||
### Usar un perfil específico:
|
||
```bash
|
||
# Opción 1: Script bash
|
||
./get_transcript_chrome.sh VIDEO_ID es chrome "Profile 1"
|
||
|
||
# Opción 2: Python
|
||
python3 fetch_transcript.py VIDEO_ID es "chrome:Profile 1"
|
||
|
||
# Opción 3: yt-dlp directo
|
||
yt-dlp --cookies-from-browser "chrome:Profile 1" \
|
||
--skip-download --write-auto-sub \
|
||
--sub-lang es --sub-format vtt \
|
||
-o "%(id)s.%(ext)s" \
|
||
"https://www.youtube.com/watch?v=VIDEO_ID"
|
||
```
|
||
|
||
---
|
||
|
||
## ❌ Si te sale "HTTP Error 429"
|
||
|
||
YouTube está bloqueando tu IP. **Solución rápida con Tor**:
|
||
|
||
```bash
|
||
# 1. Instalar Tor
|
||
brew install tor # macOS
|
||
# sudo apt install tor # Linux
|
||
|
||
# 2. Iniciar Tor
|
||
tor &
|
||
|
||
# 3. Usar con proxy
|
||
yt-dlp --cookies-from-browser chrome \
|
||
--proxy "socks5h://127.0.0.1:9050" \
|
||
--skip-download --write-auto-sub \
|
||
--sub-lang es --sub-format vtt \
|
||
-o "%(id)s.%(ext)s" \
|
||
"https://www.youtube.com/watch?v=VIDEO_ID"
|
||
```
|
||
|
||
---
|
||
|
||
## 📊 Ejemplo Completo
|
||
|
||
```bash
|
||
# 1. Obtener transcript
|
||
./get_transcript_chrome.sh K08TM4OVLyo es chrome
|
||
|
||
# Salida:
|
||
# ✅ Archivo generado: K08TM4OVLyo.es.vtt
|
||
# 💾 Texto guardado en: K08TM4OVLyo_transcript.txt
|
||
|
||
# 2. Ver el transcript
|
||
cat K08TM4OVLyo_transcript.txt
|
||
|
||
# 3. Subir al API (opcional)
|
||
curl -X POST "http://127.0.0.1:8000/upload_vtt/K08TM4OVLyo" \
|
||
-F "file=@K08TM4OVLyo.es.vtt" | jq .
|
||
```
|
||
|
||
---
|
||
|
||
## 🆘 Problemas Comunes
|
||
|
||
| Problema | Solución |
|
||
|----------|----------|
|
||
| "Unable to extract cookies" | Cierra Chrome: `killall "Google Chrome"` |
|
||
| "HTTP Error 429" | Usa Tor/VPN (ver arriba) |
|
||
| No se genera archivo | Verifica que estés logueado en YouTube |
|
||
| "yt-dlp not found" | Instala: `pip install yt-dlp` |
|
||
|
||
---
|
||
|
||
## 📚 Más Información
|
||
|
||
- **Guía completa Chrome**: `GUIA_CHROME_TRANSCRIPTS.md`
|
||
- **Soluciones HTTP 429**: `SOLUCION_HTTP_429_TRANSCRIPT.md`
|
||
- **API Endpoints**: Consulta `/docs` de la API
|
||
|
||
---
|
||
|
||
## 🎬 Demo de 30 segundos
|
||
|
||
```bash
|
||
# Instalar yt-dlp (si no lo tienes)
|
||
pip install yt-dlp
|
||
|
||
# Obtener transcript
|
||
yt-dlp --cookies-from-browser chrome --skip-download --write-auto-sub \
|
||
--sub-lang es --sub-format vtt -o "%(id)s.%(ext)s" \
|
||
"https://www.youtube.com/watch?v=K08TM4OVLyo"
|
||
|
||
# Convertir a texto plano
|
||
grep -v "WEBVTT" K08TM4OVLyo.es.vtt | grep -v "^$" | grep -v "^[0-9][0-9]:" > transcript.txt
|
||
|
||
# Ver el transcript
|
||
cat transcript.txt
|
||
```
|
||
|
||
**¡Listo! 🎉**
|
||
|
||
---
|
||
|
||
**Última actualización**: 2025-02-22
|