Spaces:
Running
Running
File size: 901 Bytes
3bd4682 61ee6e3 3bd4682 61ee6e3 |
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 |
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() |