HenzHosting's picture
Update app.py
3bd4682 verified
raw
history blame contribute delete
901 Bytes
import yt_dlp
import gradio as gr
def download_video(video_url):
try:
# Set download options
ydl_opts = {
'outtmpl': '%(title)s.%(ext)s', # Save file with video title as the name
'format': 'best', # Download the best available format
}
# Download the video
with yt_dlp.YoutubeDL(ydl_opts) as ydl:
info_dict = ydl.extract_info(video_url, download=True)
video_title = info_dict.get('title', 'Video')
return f"βœ… Downloaded: {video_title}"
except Exception as e:
return f"❌ Error: {str(e)}"
# Create Gradio interface
interface = gr.Interface(
fn=download_video,
inputs=gr.Textbox(label="Enter YouTube Video URL"),
outputs=gr.Textbox(label="Status"),
title="YouTube Video Downloader",
description="Enter a YouTube URL to download the video."
)
interface.launch()