developer28 commited on
Commit
75f9b66
Β·
verified Β·
1 Parent(s): e132b35

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -9
app.py CHANGED
@@ -194,7 +194,7 @@ def create_interface():
194
 
195
  def handle_download(url, cookies_path):
196
  if not url or not url.strip():
197
- return "Please enter a YouTube URL", gr.File(visible=False), gr.Button(visible=False), gr.Textbox(visible=False), None
198
 
199
  cookiefile = cookies_path.strip() if cookies_path and os.path.exists(cookies_path.strip()) else None
200
  video_info, info_message = downloader.get_video_info(url, cookiefile=cookiefile)
@@ -203,21 +203,20 @@ def create_interface():
203
 
204
  if file_path and video_info:
205
  success_message = f"{download_message}\n\nVideo downloaded successfully! Click 'Show Analysis Results' to see detailed information."
206
- return success_message, gr.File(value=file_path, visible=True), gr.Button(visible=True), gr.Textbox(visible=False), video_info
207
  elif file_path:
208
- return f"{download_message}\n\nVideo downloaded but analysis data unavailable.", gr.File(value=file_path, visible=True), gr.Button(visible=False), gr.Textbox(visible=False), None
209
  else:
210
- return f"❌ Download failed:\n{download_message}", gr.File(visible=False), gr.Button(visible=False), gr.Textbox(visible=False), None
211
 
212
  def show_analysis(video_info):
213
  if video_info:
214
- analysis_report = downloader.format_video_info(video_info)
215
- return gr.Textbox(value=analysis_report, visible=True)
216
- return gr.Textbox(value="❌ No analysis data available.", visible=True)
217
 
218
- download_btn.click(handle_download, inputs=[url_input, cookies_input], outputs=[status_output, file_output, analysis_btn, analysis_output, video_info_state])
219
  analysis_btn.click(show_analysis, inputs=[video_info_state], outputs=[analysis_output])
220
- url_input.submit(handle_download, inputs=[url_input, cookies_input], outputs=[status_output, file_output, analysis_btn, analysis_output, video_info_state])
221
 
222
  return demo
223
 
 
194
 
195
  def handle_download(url, cookies_path):
196
  if not url or not url.strip():
197
+ return "Please enter a YouTube URL", gr.File(visible=False), gr.Button(visible=False), None
198
 
199
  cookiefile = cookies_path.strip() if cookies_path and os.path.exists(cookies_path.strip()) else None
200
  video_info, info_message = downloader.get_video_info(url, cookiefile=cookiefile)
 
203
 
204
  if file_path and video_info:
205
  success_message = f"{download_message}\n\nVideo downloaded successfully! Click 'Show Analysis Results' to see detailed information."
206
+ return success_message, gr.File(value=file_path, visible=True), gr.Button(visible=True), video_info
207
  elif file_path:
208
+ return f"{download_message}\n\nVideo downloaded but analysis data unavailable.", gr.File(value=file_path, visible=True), gr.Button(visible=False), None
209
  else:
210
+ return f"❌ Download failed:\n{download_message}", gr.File(visible=False), gr.Button(visible=False), None
211
 
212
  def show_analysis(video_info):
213
  if video_info:
214
+ return downloader.format_video_info(video_info), gr.Textbox(visible=True)
215
+ return "❌ No analysis data available.", gr.Textbox(visible=True)
 
216
 
217
+ download_btn.click(handle_download, inputs=[url_input, cookies_input], outputs=[status_output, file_output, analysis_btn, video_info_state])
218
  analysis_btn.click(show_analysis, inputs=[video_info_state], outputs=[analysis_output])
219
+ url_input.submit(handle_download, inputs=[url_input, cookies_input], outputs=[status_output, file_output, analysis_btn, video_info_state])
220
 
221
  return demo
222