JUNGU commited on
Commit
c0b7006
·
verified ·
1 Parent(s): 4f574fb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -5
app.py CHANGED
@@ -24,11 +24,9 @@ def extract_info(youtube_url):
24
 
25
  formats = info.get('formats', [])
26
 
27
- # 최고 품질의 mp4 (비디오만)
28
  best_video_only = max((f for f in formats if f['ext'] == 'mp4' and f.get('vcodec') != 'none' and f.get('acodec') == 'none'),
29
  key=lambda x: x.get('height', 0), default=None)
30
 
31
- # 최고 품질의 통합 스트림 (비디오+오디오)
32
  best_combined = max((f for f in formats if f['ext'] == 'mp4' and f.get('vcodec') != 'none' and f.get('acodec') != 'none'),
33
  key=lambda x: x.get('height', 0), default=None)
34
 
@@ -60,19 +58,29 @@ with gr.Blocks() as demo:
60
  video_only_button = gr.Button("비디오만 다운로드", visible=False)
61
  combined_button = gr.Button("비디오+오디오 다운로드", visible=False)
62
 
 
 
 
 
 
 
 
 
 
 
63
  extract_button.click(
64
  fn=extract_info,
65
  inputs=youtube_url_input,
66
- outputs=[output, video_only_button, combined_button, video_only_button, combined_button]
67
  )
68
  video_only_button.click(
69
  fn=on_download_click,
70
- inputs=video_only_button,
71
  outputs=gr.HTML()
72
  )
73
  combined_button.click(
74
  fn=on_download_click,
75
- inputs=combined_button,
76
  outputs=gr.HTML()
77
  )
78
 
 
24
 
25
  formats = info.get('formats', [])
26
 
 
27
  best_video_only = max((f for f in formats if f['ext'] == 'mp4' and f.get('vcodec') != 'none' and f.get('acodec') == 'none'),
28
  key=lambda x: x.get('height', 0), default=None)
29
 
 
30
  best_combined = max((f for f in formats if f['ext'] == 'mp4' and f.get('vcodec') != 'none' and f.get('acodec') != 'none'),
31
  key=lambda x: x.get('height', 0), default=None)
32
 
 
58
  video_only_button = gr.Button("비디오만 다운로드", visible=False)
59
  combined_button = gr.Button("비디오+오디오 다운로드", visible=False)
60
 
61
+ video_only_url = gr.State()
62
+ combined_url = gr.State()
63
+
64
+ def update_urls(metadata, video_url, combined_url, video_visibility, combined_visibility):
65
+ return (metadata,
66
+ gr.update(visible=video_visibility),
67
+ gr.update(visible=combined_visibility),
68
+ video_url,
69
+ combined_url)
70
+
71
  extract_button.click(
72
  fn=extract_info,
73
  inputs=youtube_url_input,
74
+ outputs=[output, video_only_button, combined_button, video_only_url, combined_url]
75
  )
76
  video_only_button.click(
77
  fn=on_download_click,
78
+ inputs=video_only_url,
79
  outputs=gr.HTML()
80
  )
81
  combined_button.click(
82
  fn=on_download_click,
83
+ inputs=combined_url,
84
  outputs=gr.HTML()
85
  )
86