| import yt_dlp |
| import gradio as gr |
|
|
| def download_video(video_url): |
| try: |
| |
| ydl_opts = { |
| 'outtmpl': '%(title)s.%(ext)s', |
| 'format': 'best', |
| } |
|
|
| |
| 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)}" |
|
|
| |
| 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() |