Spaces:
Running
Running
Update UI
Browse files
app.py
CHANGED
|
@@ -128,6 +128,19 @@ def fetch_stats_for_selected(selected_datasets: List[str], progress=gr.Progress(
|
|
| 128 |
if 'unknown' in v3_by_date:
|
| 129 |
sorted_dates.append('unknown')
|
| 130 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 131 |
for date_key in sorted_dates:
|
| 132 |
datasets = v3_by_date[date_key]
|
| 133 |
date_display = datasets[0]['date_display']
|
|
@@ -142,12 +155,7 @@ def fetch_stats_for_selected(selected_datasets: List[str], progress=gr.Progress(
|
|
| 142 |
date_total_seconds += info_meta['total_frames'] / fps
|
| 143 |
|
| 144 |
# Format total duration
|
| 145 |
-
|
| 146 |
-
total_minutes = int(date_total_seconds // 60)
|
| 147 |
-
total_seconds = int(date_total_seconds % 60)
|
| 148 |
-
duration_str = f" • {total_minutes}m {total_seconds}s"
|
| 149 |
-
else:
|
| 150 |
-
duration_str = f" • {int(date_total_seconds)}s"
|
| 151 |
|
| 152 |
output.append(f"**{date_display}** — Total: **{date_total_episodes} episodes**{duration_str}")
|
| 153 |
|
|
@@ -157,24 +165,16 @@ def fetch_stats_for_selected(selected_datasets: List[str], progress=gr.Progress(
|
|
| 157 |
|
| 158 |
# Add metadata if available
|
| 159 |
info_meta = dataset['stats'].get('info_metadata', {})
|
| 160 |
-
extra_info = []
|
| 161 |
|
| 162 |
# Calculate duration in seconds from frames
|
|
|
|
| 163 |
if info_meta.get('total_frames'):
|
| 164 |
total_frames = info_meta['total_frames']
|
| 165 |
fps = info_meta.get('fps', 30) # Default to 30 if not specified
|
| 166 |
duration_seconds = total_frames / fps
|
| 167 |
-
|
| 168 |
-
# Format duration nicely
|
| 169 |
-
if duration_seconds >= 60:
|
| 170 |
-
minutes = int(duration_seconds // 60)
|
| 171 |
-
seconds = int(duration_seconds % 60)
|
| 172 |
-
extra_info.append(f"{minutes}m {seconds}s")
|
| 173 |
-
else:
|
| 174 |
-
extra_info.append(f"{int(duration_seconds)}s")
|
| 175 |
|
| 176 |
-
|
| 177 |
-
output.append(f" • `{repo_name}`: **{episodes} episodes**{extra_str}")
|
| 178 |
|
| 179 |
output.append("") # Empty line between dates
|
| 180 |
|
|
|
|
| 128 |
if 'unknown' in v3_by_date:
|
| 129 |
sorted_dates.append('unknown')
|
| 130 |
|
| 131 |
+
def format_duration(seconds):
|
| 132 |
+
"""Format duration as hours, minutes, seconds"""
|
| 133 |
+
hours = int(seconds // 3600)
|
| 134 |
+
minutes = int((seconds % 3600) // 60)
|
| 135 |
+
secs = int(seconds % 60)
|
| 136 |
+
|
| 137 |
+
if hours > 0:
|
| 138 |
+
return f"{hours}h {minutes}m {secs}s"
|
| 139 |
+
elif minutes > 0:
|
| 140 |
+
return f"{minutes}m {secs}s"
|
| 141 |
+
else:
|
| 142 |
+
return f"{secs}s"
|
| 143 |
+
|
| 144 |
for date_key in sorted_dates:
|
| 145 |
datasets = v3_by_date[date_key]
|
| 146 |
date_display = datasets[0]['date_display']
|
|
|
|
| 155 |
date_total_seconds += info_meta['total_frames'] / fps
|
| 156 |
|
| 157 |
# Format total duration
|
| 158 |
+
duration_str = f" • {format_duration(date_total_seconds)}"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 159 |
|
| 160 |
output.append(f"**{date_display}** — Total: **{date_total_episodes} episodes**{duration_str}")
|
| 161 |
|
|
|
|
| 165 |
|
| 166 |
# Add metadata if available
|
| 167 |
info_meta = dataset['stats'].get('info_metadata', {})
|
|
|
|
| 168 |
|
| 169 |
# Calculate duration in seconds from frames
|
| 170 |
+
duration_str = ""
|
| 171 |
if info_meta.get('total_frames'):
|
| 172 |
total_frames = info_meta['total_frames']
|
| 173 |
fps = info_meta.get('fps', 30) # Default to 30 if not specified
|
| 174 |
duration_seconds = total_frames / fps
|
| 175 |
+
duration_str = f" • {format_duration(duration_seconds)}"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 176 |
|
| 177 |
+
output.append(f" • `{repo_name}`: **{episodes} episodes**{duration_str}")
|
|
|
|
| 178 |
|
| 179 |
output.append("") # Empty line between dates
|
| 180 |
|