File size: 922 Bytes
3668b05
d6f3571
3668b05
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import gradio as gr
import youtube_download
import time

def download_video(url):
    ydl_opts = {
        'format': 'best',
        'outtmpl': '%(title)s.%(ext)s',
        'postprocessors': [{
            'key': 'FFmpegVideoConvertor',
            'preferedformat': 'mp4',
        }],
    }
    with youtube_dl.YoutubeDL(ydl_opts) as ydl:
        ydl.download([url])
    time.sleep(10)  # Simulate delay for downloading
    return f"Video downloaded from {url}"

iface = gr.Interface(fn=download_video, 
                     inputs=gr.Textbox(label="Enter YouTube Video URL"), 
                     outputs=gr.Textbox(label="Download Status"),
                     title="YouTube Video Downloader",
                     description="Paste the link to the YouTube video and click the button to download it. The video will be available for download after 10 seconds.",
                     theme="default")

iface.launch()