Update app.py
Browse files
app.py
CHANGED
|
@@ -6,9 +6,9 @@ def download_video(url):
|
|
| 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 |
# Creating a pink theme
|
| 14 |
pink_theme = gr.themes.Default(
|
|
@@ -19,16 +19,17 @@ pink_theme = gr.themes.Default(
|
|
| 19 |
with gr.Blocks(theme=pink_theme) as interface:
|
| 20 |
gr.Markdown(
|
| 21 |
"""
|
| 22 |
-
|
| 23 |
|
| 24 |
-
This app
|
| 25 |
-
|
| 26 |
"""
|
| 27 |
)
|
| 28 |
with gr.Row():
|
| 29 |
-
url_textbox = gr.Textbox(label="Paste the YouTube Video URL Here")
|
| 30 |
-
download_button = gr.Button("Download 📥")
|
| 31 |
video_output = gr.Video(label="Downloaded Video 📺")
|
| 32 |
-
|
|
|
|
|
|
|
| 33 |
|
| 34 |
interface.launch()
|
|
|
|
| 6 |
yt = YouTube(url)
|
| 7 |
highest_res_stream = yt.streams.get_highest_resolution()
|
| 8 |
video_path = highest_res_stream.download()
|
| 9 |
+
return video_path, "Video downloaded successfully!" # Return message for display
|
| 10 |
except Exception as e:
|
| 11 |
+
return None, f"Error: {e}" # Return error message for display
|
| 12 |
|
| 13 |
# Creating a pink theme
|
| 14 |
pink_theme = gr.themes.Default(
|
|
|
|
| 19 |
with gr.Blocks(theme=pink_theme) as interface:
|
| 20 |
gr.Markdown(
|
| 21 |
"""
|
| 22 |
+
# 💖 Downloads: YouTube Video Downloader 💖
|
| 23 |
|
| 24 |
+
This app automatically downloads YouTube videos in the highest available resolution
|
| 25 |
+
as soon as you paste the video URL.
|
| 26 |
"""
|
| 27 |
)
|
| 28 |
with gr.Row():
|
| 29 |
+
url_textbox = gr.Textbox(label="Paste the YouTube Video URL Here" )
|
|
|
|
| 30 |
video_output = gr.Video(label="Downloaded Video 📺")
|
| 31 |
+
message_output = gr.Textbox(label="Status Message") # To display success/error messages
|
| 32 |
+
|
| 33 |
+
url_textbox.submit(download_video, inputs=url_textbox, outputs=[video_output, message_output])
|
| 34 |
|
| 35 |
interface.launch()
|