Jekyll2000 commited on
Commit
68239f3
1 Parent(s): aa7f4bd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -18
app.py CHANGED
@@ -33,28 +33,33 @@ def download_media(url, download_video):
33
 
34
  return output_file
35
 
36
- def download_handler(url, download_video):
37
- if url:
38
- output_file = download_media(url, download_video)
39
- return "Download completed!", output_file
40
  else:
41
- return "Please enter a YouTube URL", None
42
 
43
- with gr.Blocks() as demo:
44
- gr.Markdown("# Download From YOUTUBE")
45
- gr.Markdown("## Download MP3/MP4 from YouTube URL")
46
-
47
- url = gr.Textbox(label="YouTube URL")
48
- download_video = gr.Checkbox(label="Download Video", value=False)
49
- download_btn = gr.Button("Download")
50
 
51
- output_text = gr.Markdown()
52
- output_file = gr.File()
53
-
54
- download_btn.click(download_handler, inputs=[url, download_video], outputs=[output_text, output_file])
 
 
 
 
 
55
 
 
 
 
 
 
56
 
57
- gr.Markdown("Build AI with Haseeb Ahmed (AI/ML engineer)")
58
- gr.Markdown("### Made with ❤ by [Haseeb Ahmed](https://www.linkedin.com/in/muhammad-haseeb-ahmed-1954b5230/)")
59
 
60
  demo.launch()
 
33
 
34
  return output_file
35
 
36
+ def handle_download(url, download_video):
37
+ output_file = download_media(url, download_video)
38
+ if download_video:
39
+ return gr.update(value=output_file, visible=True), gr.update(visible=False)
40
  else:
41
+ return gr.update(visible=False), gr.update(value=output_file, visible=True)
42
 
43
+ with gr.Blocks(theme=gr.themes.Soft(primary_hue="orange", secondary_hue="orange")) as demo:
44
+ gr.Markdown(f"# <div style='text-align: center;'>YOUTUBE Downloader</div>")
45
+ gr.Markdown(f"## <div style='text-align: center;'>Download MP3/MP4 from YouTube URL</div>")
 
 
 
 
46
 
47
+ with gr.Row():
48
+ url_input = gr.Textbox(label="YouTube URL")
49
+ with gr.Row():
50
+ download_video_checkbox = gr.Checkbox(label="Download Video", value=False)
51
+ with gr.Row():
52
+ download_button = gr.Button("Download")
53
+ with gr.Row():
54
+ output_audio = gr.Audio(label="Downloaded Media", visible=False)
55
+ output_file = gr.File(label="Downloaded Media", visible=False)
56
 
57
+ download_button.click(
58
+ handle_download,
59
+ inputs=[url_input, download_video_checkbox],
60
+ outputs=[output_file, output_audio]
61
+ )
62
 
63
+ gr.Markdown(f"### <div style='text-align: center;'>Made with by <a href='https://huggingface.co/Gradio-Blocks'>Gradio-Blocks-Party-Member</a></div>")
 
64
 
65
  demo.launch()