Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from pytube import YouTube
|
3 |
+
|
4 |
+
def download_video(url):
|
5 |
+
try:
|
6 |
+
yt = YouTube(url)
|
7 |
+
highest_res_stream = yt.streams.get_highest_resolution()
|
8 |
+
video_path = highest_res_stream.download()
|
9 |
+
return video_path
|
10 |
+
except Exception as e:
|
11 |
+
return f"Error: {e}"
|
12 |
+
|
13 |
+
iface = gr.Interface(
|
14 |
+
fn=download_video,
|
15 |
+
inputs=gr.Textbox(label="YouTube Video URL"),
|
16 |
+
outputs=gr.Video(label="Downloaded Video"),
|
17 |
+
title="YouTube Video Downloader",
|
18 |
+
description="Enter the URL of a YouTube video to download it.",
|
19 |
+
)
|
20 |
+
|
21 |
+
iface.launch()
|