DHEIVER's picture
Update app.py
3603dd8 verified
raw
history blame contribute delete
999 Bytes
import gradio as gr
from pytube import YouTube
import os
def download_youtube_video(url):
try:
# Criar a pasta de downloads, se não existir
os.makedirs("downloads", exist_ok=True)
# Baixar o vídeo usando pytube
yt = YouTube(url)
video_stream = yt.streams.filter(file_extension='mp4').get_highest_resolution()
downloaded_file_path = video_stream.download(output_path="downloads")
# Retornar o caminho do vídeo baixado
return downloaded_file_path
except Exception as e:
return f"Erro ao baixar o vídeo: {str(e)}"
# Interface Gradio
iface = gr.Interface(
fn=download_youtube_video,
inputs=gr.Textbox(label="Link do YouTube", placeholder="Cole o link do vídeo aqui..."),
outputs=gr.Video(label="Vídeo Baixado"),
title="Download de Vídeos do YouTube",
description="Cole o link de um vídeo do YouTube para baixá-lo em formato MP4."
)
# Iniciar a interface
iface.launch()