File size: 686 Bytes
e84775b
8acf2f8
720c5af
8acf2f8
0f66410
8acf2f8
 
 
 
e84775b
8acf2f8
0f66410
8acf2f8
 
 
 
 
 
 
 
0f66410
8acf2f8
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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()