Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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),
|
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),
|
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),
|
209 |
else:
|
210 |
-
return f"β Download failed:\n{download_message}", gr.File(visible=False), gr.Button(visible=False),
|
211 |
|
212 |
def show_analysis(video_info):
|
213 |
if video_info:
|
214 |
-
|
215 |
-
|
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,
|
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,
|
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 |
|