Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -5,6 +5,8 @@ import tempfile
|
|
5 |
import shutil
|
6 |
from pathlib import Path
|
7 |
import re
|
|
|
|
|
8 |
|
9 |
class YouTubeDownloader:
|
10 |
def __init__(self):
|
@@ -190,7 +192,8 @@ def create_interface():
|
|
190 |
file_output = gr.File(label="Downloaded Video", visible=False)
|
191 |
analysis_btn = gr.Button("Show Analysis Results", visible=False)
|
192 |
analysis_output = gr.Textbox(label="Video Analysis Results", visible=False, lines=20)
|
193 |
-
video_info_state = gr.
|
|
|
194 |
|
195 |
def handle_download(url, cookies_path):
|
196 |
if not url or not url.strip():
|
@@ -205,12 +208,13 @@ def create_interface():
|
|
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.State(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.State(
|
209 |
else:
|
210 |
return f"β Download failed:\n{download_message}", gr.File(visible=False), gr.Button(visible=False), gr.State(None)
|
211 |
|
212 |
def show_analysis(video_info):
|
213 |
-
print("[DEBUG] Received
|
|
|
214 |
if video_info:
|
215 |
return downloader.format_video_info(video_info), gr.Textbox(visible=True)
|
216 |
return "β No analysis data available.", gr.Textbox(visible=True)
|
|
|
5 |
import shutil
|
6 |
from pathlib import Path
|
7 |
import re
|
8 |
+
import uuid
|
9 |
+
session_data = {}
|
10 |
|
11 |
class YouTubeDownloader:
|
12 |
def __init__(self):
|
|
|
192 |
file_output = gr.File(label="Downloaded Video", visible=False)
|
193 |
analysis_btn = gr.Button("Show Analysis Results", visible=False)
|
194 |
analysis_output = gr.Textbox(label="Video Analysis Results", visible=False, lines=20)
|
195 |
+
video_info_state = gr.Textbox(value=False)
|
196 |
+
|
197 |
|
198 |
def handle_download(url, cookies_path):
|
199 |
if not url or not url.strip():
|
|
|
208 |
success_message = f"{download_message}\n\nVideo downloaded successfully! Click 'Show Analysis Results' to see detailed information."
|
209 |
return success_message, gr.File(value=file_path, visible=True), gr.Button(visible=True), gr.State(video_info)
|
210 |
elif file_path:
|
211 |
+
return f"{download_message}\n\nVideo downloaded but analysis data unavailable.", gr.File(value=file_path, visible=True), gr.Button(visible=False), gr.State("")
|
212 |
else:
|
213 |
return f"β Download failed:\n{download_message}", gr.File(visible=False), gr.Button(visible=False), gr.State(None)
|
214 |
|
215 |
def show_analysis(video_info):
|
216 |
+
print("[DEBUG] Received session_id:", session_id)
|
217 |
+
video_info = session_data.get(session_id)
|
218 |
if video_info:
|
219 |
return downloader.format_video_info(video_info), gr.Textbox(visible=True)
|
220 |
return "β No analysis data available.", gr.Textbox(visible=True)
|