| import gradio as gr |
| from pytube import YouTube |
| import os |
|
|
| def download_youtube_video(url): |
| try: |
| |
| yt = YouTube(url) |
| |
| stream = yt.streams.filter(progressive=True, file_extension='mp4').order_by('resolution').desc().first() |
| if stream is None: |
| return "No se encontr贸 un stream adecuado para descargar." |
| |
| |
| download_folder = "downloads" |
| os.makedirs(download_folder, exist_ok=True) |
| |
| |
| output_path = stream.download(output_path=download_folder) |
| return f"Video descargado: {output_path}" |
| except Exception as e: |
| return f"Error al descargar el v铆deo: {str(e)}" |
|
|
| |
| iface = gr.Interface( |
| fn=download_youtube_video, |
| inputs=gr.Textbox(label="URL del v铆deo de YouTube", placeholder="Ingresa la URL aqu铆..."), |
| outputs=gr.Textbox(label="Resultado"), |
| title="Descargador de V铆deos de YouTube", |
| description="Ingresa la URL de un v铆deo de YouTube y descarga la versi贸n en MP4 de mayor resoluci贸n disponible." |
| ) |
|
|
| if __name__ == "__main__": |
| iface.launch() |
|
|
|
|