Xhaheen commited on
Commit
d4615f3
Β·
verified Β·
1 Parent(s): 9eab490

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -8
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
- Downloads: YouTube Video Downloader πŸ’–
23
 
24
- This app lets you download YouTube videos in the highest available resolution.
25
- Just paste the video URL and click "Download"!
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
- download_button.click(download_video, inputs=url_textbox, outputs=video_output)
 
 
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()