Hev832 commited on
Commit
2cb5213
·
verified ·
1 Parent(s): ee31586

Update run.py

Browse files
Files changed (1) hide show
  1. run.py +3 -5
run.py CHANGED
@@ -33,7 +33,7 @@ def download_youtube(url, file_format):
33
 
34
  def show_output(file_path, error):
35
  if error:
36
- return error, None, None
37
  if file_path.endswith(".mp3"):
38
  return None, gr.Audio.update(value=file_path, visible=True), gr.Video.update(visible=False)
39
  else:
@@ -46,12 +46,10 @@ with gr.Blocks() as demo:
46
  format_input = gr.Dropdown(choices=["audio", "video"], label="Format")
47
  download_button = gr.Button("Download")
48
  with gr.Column():
49
- error_output = gr.Textbox(label="Error Output", visible=False)
50
  audio_output = gr.Audio(label="Audio Output", visible=False)
51
  video_output = gr.Video(label="Video Output", visible=False)
52
 
53
- download_button.click(download_youtube, inputs=[url_input, format_input], outputs=[error_output, audio_output, video_output]).then(
54
- show_output, inputs=[error_output, audio_output], outputs=[error_output, audio_output, video_output]
55
- )
56
 
57
  demo.launch()
 
33
 
34
  def show_output(file_path, error):
35
  if error:
36
+ return error, gr.Audio.update(visible=False), gr.Video.update(visible=False)
37
  if file_path.endswith(".mp3"):
38
  return None, gr.Audio.update(value=file_path, visible=True), gr.Video.update(visible=False)
39
  else:
 
46
  format_input = gr.Dropdown(choices=["audio", "video"], label="Format")
47
  download_button = gr.Button("Download")
48
  with gr.Column():
49
+ error_output = gr.Textbox(label="Error Output", visible=True)
50
  audio_output = gr.Audio(label="Audio Output", visible=False)
51
  video_output = gr.Video(label="Video Output", visible=False)
52
 
53
+ download_button.click(download_youtube, inputs=[url_input, format_input], outputs=[error_output, audio_output, video_output])
 
 
54
 
55
  demo.launch()