|
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 |
|
except Exception as e: |
|
return f"Error: {e}" |
|
|
|
iface = gr.Interface( |
|
fn=download_video, |
|
inputs=gr.Textbox(label="YouTube Video URL"), |
|
outputs=gr.Video(label="Downloaded Video"), |
|
title="YouTube Video Downloader", |
|
description="Enter the URL of a YouTube video to download it.", |
|
) |
|
|
|
iface.launch() |