Descarga videos de YouTube de manera fácil rápida y segura
#Instalar la libreria yt-dlp
>>!pip install -U "yt-dlp[default]"
Collecting yt-dlp[default]
Downloading yt_dlp-2026.7.4-py3-none-any.whl.metadata (183 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 183.8/183.8 kB 9.0 MB/s eta 0:00:00
Requirement already satisfied: brotli in /usr/local/lib/python3.12/dist-packages (from yt-dlp[default]) (1.2.0)
Requirement already satisfied: certifi in /usr/local/lib/python3.12/dist-packages (from yt-dlp[default]) (2026.6.17)
Collecting mutagen (from yt-dlp[default])
Downloading mutagen-1.48.1-py3-none-any.whl.metadata (1.8 kB)
Requirement already satisfied: pycryptodomex in /usr/local/lib/python3.12/dist-packages (from yt-dlp[default]) (3.23.0)
Requirement already satisfied: requests<3,>=2.32.2 in /usr/local/lib/python3.12/dist-packages (from yt-dlp[default]) (2.32.4)
Requirement already satisfied: urllib3<3,>=2.0.2 in /usr/local/lib/python3.12/dist-packages (from yt-dlp[default]) (2.5.0)
Requirement already satisfied: websockets>=13.0 in /usr/local/lib/python3.12/dist-packages (from yt-dlp[default]) (15.0.1)
Collecting yt-dlp-ejs==0.8.0 (from yt-dlp[default])
Downloading yt_dlp_ejs-0.8.0-py3-none-any.whl.metadata (3.5 kB)
Requirement already satisfied: charset_normalizer<4,>=2 in /usr/local/lib/python3.12/dist-packages (from requests<3,>=2.32.2->yt-dlp[default]) (3.4.9)
Requirement already satisfied: idna<4,>=2.5 in /usr/local/lib/python3.12/dist-packages (from requests<3,>=2.32.2->yt-dlp[default]) (3.18)
Downloading yt_dlp_ejs-0.8.0-py3-none-any.whl (53 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 53.4/53.4 kB 2.9 MB/s eta 0:00:00
Downloading mutagen-1.48.1-py3-none-any.whl (195 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 195.7/195.7 kB 12.3 MB/s eta 0:00:00
Downloading yt_dlp-2026.7.4-py3-none-any.whl (3.2 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 3.2/3.2 MB 80.9 MB/s eta 0:00:00
Installing collected packages: yt-dlp-ejs, yt-dlp, mutagen
Successfully installed mutagen-1.48.1 yt-dlp-2026.7.4 yt-dlp-ejs-0.8.0
# Descargar video sin convertir a otro fromato.
>>import yt_dlp
# 1. Configura el enlace del video
>>url_video = "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
# 2. Configura las opciones (en este caso, descargar la mejor calidad de video y audio combinados)
>>ydl_opts = {
'format': 'bestvideo+bestaudio/best',
'outtmpl': '%(title)s.%(ext)s', # Guarda el archivo con el nombre del video original
}
# 3. Ejecuta la descarga
>>print("Iniciando descarga en los servidores de Google...")
>>with yt_dlp.YoutubeDL(ydl_opts) as ydl:
ydl.download([url_video])
>>print("¡Descarga completada con éxito!")
Si lo que deseas es solo descargar el audio del video este es el código:
import yt_dlp
>># 1. Configura el enlace del video o canción
>>url_audio = input("Por favor pegue aqui el link del video de youtube, que desea descargar y convertir a audio mp3: ")
>># 2. Configuración específica para extraer solo el audio en MP3
>>ydl_opts = {
'format': 'bestaudio/best', # Descarga solo el flujo de mejor audio disponible
'outtmpl': '%(title)s.%(ext)s', # Guarda el archivo con el título original
'postprocessors': [{ # Este bloque le ordena a Python convertir el archivo a MP3
'key': 'FFmpegExtractAudio',
'preferredcodec': 'mp3',
'preferredquality': '320', # Máxima calidad de audio (320 kbps)
}],
}
>># 3. Ejecuta el proceso
>>print("Extrayendo y convirtiendo el audio a MP3 en los servidores de Google...")
>>with yt_dlp.YoutubeDL(ydl_opts) as ydl:
>> ydl.download([url_audio])
>>print("¡Conversión a MP3 completada con éxito!")
Si lo haces en google colab, debes buscar el archivo en el panel de la izquierda.
Por favor pegue aqui el link del video de youtube, que desea descargar y convertir a audio mp3: https://youtu.be/zU9V9QMXeyc?si=cTJ4lXPdb9eIlQy9 Extrayendo y convirtiendo el audio a MP3 en los servidores de Google... [youtube] Extracting URL: https://youtu.be/zU9V9QMXeyc?si=cTJ4lXPdb9eIlQy9 [youtube] zU9V9QMXeyc: Downloading webpage
WARNING: [youtube] No supported JavaScript runtime could be found. Only deno is enabled by default; to use another runtime add --js-runtimes RUNTIME[:PATH] to your command/config. YouTube extraction without a JS runtime has been deprecated, and some formats may be missing. See https://github.com/yt-dlp/yt-dlp/wiki/EJS for details on installing one
[youtube] zU9V9QMXeyc: Downloading android vr player API JSON [info] zU9V9QMXeyc: Downloading 1 format(s): 251 [download] Destination: Pussy.webm [download] 100% of 3.58MiB in 00:00:00 at 13.77MiB/s [ExtractAudio] Destination: Pussy.mp3 Deleting original file Pussy.webm (pass -k to keep) ¡Conversión a MP3 completada con éxito!
No hay comentarios.:
Publicar un comentario