Spaces:
Running
Running
File size: 999 Bytes
091e634 3603dd8 091e634 3db65c1 a88c09a 3603dd8 a88c09a 091e634 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
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() |