File size: 1,177 Bytes
4f67e8c
 
 
 
9eab490
 
 
 
d4615f3
9eab490
d4615f3
4f67e8c
9eab490
 
 
 
4f67e8c
 
9eab490
 
 
d4615f3
9eab490
d4615f3
 
9eab490
 
 
d4615f3
9eab490
d4615f3
 
 
9eab490
 
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
30
31
32
33
34
35
import gradio as gr
from pytube import YouTube

def download_video(url):
    try:
        yt = YouTube(url)
        highest_res_stream = yt.streams.get_highest_resolution()
        video_path = highest_res_stream.download()
        return video_path, "Video downloaded successfully!"  # Return message for display
    except Exception as e:
        return None, f"Error: {e}"  # Return error message for display

# Creating a pink theme
pink_theme = gr.themes.Default(
    primary_hue="pink",
    secondary_hue="rose",
)

with gr.Blocks(theme=pink_theme) as interface:
    gr.Markdown(
        """
        # πŸ’– Downloads: YouTube Video Downloader πŸ’–

        This app automatically downloads YouTube videos in the highest available resolution 
        as soon as you paste the video URL. 
        """
    )
    with gr.Row():
        url_textbox = gr.Textbox(label="Paste the YouTube Video URL Here" )
    video_output = gr.Video(label="Downloaded Video πŸ“Ί")
    message_output = gr.Textbox(label="Status Message")  # To display success/error messages

    url_textbox.submit(download_video, inputs=url_textbox, outputs=[video_output, message_output])

interface.launch()