|
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!" |
|
except Exception as e: |
|
return None, f"Error: {e}" |
|
|
|
|
|
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") |
|
|
|
url_textbox.submit(download_video, inputs=url_textbox, outputs=[video_output, message_output]) |
|
|
|
interface.launch() |