speedyurl / app.py
joermd's picture
Update app.py
8acf2f8 verified
raw
history blame
686 Bytes
import gradio as gr
from pytube import YouTube
def download_video(url):
try:
yt = YouTube(url)
stream = yt.streams.get_highest_resolution()
stream.download(output_path="downloads", filename=f"{yt.title}.mp4")
return f"Downloaded: {yt.title}.mp4"
except Exception as e:
return f"An error occurred: {e}"
# Create a Gradio interface
iface = gr.Interface(
fn=download_video,
inputs=gr.inputs.Textbox(lines=2, placeholder="Enter YouTube URL..."),
outputs="text",
title="YouTube Video Downloader",
description="Enter the YouTube video URL and click 'Submit' to download the video."
)
# Launch the interface
iface.launch()