Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -27,7 +27,7 @@ def download_media(url, download_video):
|
|
27 |
else:
|
28 |
output_file = file_title.rsplit('.', 1)[0] + '.mp3'
|
29 |
|
30 |
-
return output_file
|
31 |
|
32 |
def get_output_component(download_video):
|
33 |
if download_video:
|
@@ -42,19 +42,22 @@ with gr.Blocks() as demo:
|
|
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 |
|
49 |
-
|
|
|
50 |
|
51 |
-
def
|
52 |
-
|
|
|
|
|
|
|
|
|
53 |
|
54 |
-
|
55 |
-
|
|
|
|
|
56 |
)
|
57 |
|
58 |
-
download_button.click(download_media, inputs=[url_input, download_video_checkbox], outputs=[dynamic_output, download_video_checkbox])
|
59 |
-
|
60 |
demo.launch()
|
|
|
27 |
else:
|
28 |
output_file = file_title.rsplit('.', 1)[0] + '.mp3'
|
29 |
|
30 |
+
return output_file
|
31 |
|
32 |
def get_output_component(download_video):
|
33 |
if download_video:
|
|
|
42 |
with gr.Row():
|
43 |
url_input = gr.Textbox(label="YouTube URL")
|
44 |
download_video_checkbox = gr.Checkbox(label="Download Video", value=False)
|
|
|
45 |
download_button = gr.Button("Download")
|
|
|
46 |
|
47 |
+
output_audio = gr.Audio(label="Downloaded Media", visible=False)
|
48 |
+
output_file = gr.File(label="Downloaded Media", visible=False)
|
49 |
|
50 |
+
def handle_download(url, download_video):
|
51 |
+
output_file = download_media(url, download_video)
|
52 |
+
if download_video:
|
53 |
+
return gr.update(value=output_file, visible=True), gr.update(visible=False)
|
54 |
+
else:
|
55 |
+
return gr.update(visible=False), gr.update(value=output_file, visible=True)
|
56 |
|
57 |
+
download_button.click(
|
58 |
+
handle_download,
|
59 |
+
inputs=[url_input, download_video_checkbox],
|
60 |
+
outputs=[output_file, output_audio]
|
61 |
)
|
62 |
|
|
|
|
|
63 |
demo.launch()
|