Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -27,19 +27,34 @@ def download_media(url, download_video):
|
|
27 |
else:
|
28 |
output_file = file_title.rsplit('.', 1)[0] + '.mp3'
|
29 |
|
30 |
-
return output_file
|
31 |
|
32 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
with gr.Blocks() as demo:
|
34 |
gr.Markdown("# YouTube Media Downloader")
|
|
|
35 |
with gr.Row():
|
36 |
url_input = gr.Textbox(label="YouTube URL")
|
37 |
-
|
38 |
-
download_video_checkbox = gr.Checkbox(label="Or Download Video", value=False)
|
39 |
with gr.Row():
|
40 |
download_button = gr.Button("Download")
|
|
|
41 |
with gr.Row():
|
42 |
-
|
43 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
44 |
|
45 |
demo.launch()
|
|
|
27 |
else:
|
28 |
output_file = file_title.rsplit('.', 1)[0] + '.mp3'
|
29 |
|
30 |
+
return output_file, download_video
|
31 |
|
32 |
+
def get_output_component(download_video):
|
33 |
+
if download_video:
|
34 |
+
return gr.File(label="Downloaded Media")
|
35 |
+
else:
|
36 |
+
return gr.Audio(label="Downloaded Media")
|
37 |
+
|
38 |
+
# Create the Gradio interface
|
39 |
with gr.Blocks() as demo:
|
40 |
gr.Markdown("# YouTube Media Downloader")
|
41 |
+
|
42 |
with gr.Row():
|
43 |
url_input = gr.Textbox(label="YouTube URL")
|
44 |
+
download_video_checkbox = gr.Checkbox(label="Download Video", value=False)
|
|
|
45 |
with gr.Row():
|
46 |
download_button = gr.Button("Download")
|
47 |
+
|
48 |
with gr.Row():
|
49 |
+
dynamic_output = gr.State()
|
50 |
+
|
51 |
+
def update_output_component(download_video):
|
52 |
+
return get_output_component(download_video)
|
53 |
+
|
54 |
+
dynamic_output = download_video_checkbox.change(
|
55 |
+
update_output_component, inputs=download_video_checkbox, outputs=dynamic_output
|
56 |
+
)
|
57 |
+
|
58 |
+
download_button.click(download_media, inputs=[url_input, download_video_checkbox], outputs=[dynamic_output, download_video_checkbox])
|
59 |
|
60 |
demo.launch()
|