Spaces:
Sleeping
Sleeping
commit 2
Browse files
app.py
CHANGED
|
@@ -128,13 +128,27 @@ async def upload_video(
|
|
| 128 |
if "error" in results:
|
| 129 |
raise HTTPException(status_code=500, detail=results["error"])
|
| 130 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 131 |
with open(analysis_path, 'w') as f:
|
| 132 |
json.dump(results, f, indent=2)
|
| 133 |
|
| 134 |
return AnalysisResponse(
|
| 135 |
success=True,
|
| 136 |
message="Video description generated successfully",
|
| 137 |
-
video_description=
|
| 138 |
highlights=output_path,
|
| 139 |
analysis_file=analysis_path
|
| 140 |
)
|
|
|
|
| 128 |
if "error" in results:
|
| 129 |
raise HTTPException(status_code=500, detail=results["error"])
|
| 130 |
|
| 131 |
+
selected_set = str(results.get("selected_set", "")).strip()
|
| 132 |
+
if selected_set == "1":
|
| 133 |
+
enriched_description = results.get("highlights1", "")
|
| 134 |
+
elif selected_set == "2":
|
| 135 |
+
enriched_description = results.get("highlights2", "")
|
| 136 |
+
else:
|
| 137 |
+
h1 = results.get("highlights1", "")
|
| 138 |
+
h2 = results.get("highlights2", "")
|
| 139 |
+
base_desc = results.get("video_description", "")
|
| 140 |
+
enriched_description = h1 or h2 or base_desc
|
| 141 |
+
|
| 142 |
+
# Keep API and analysis JSON aligned with requested description behavior.
|
| 143 |
+
results["video_description"] = enriched_description
|
| 144 |
+
|
| 145 |
with open(analysis_path, 'w') as f:
|
| 146 |
json.dump(results, f, indent=2)
|
| 147 |
|
| 148 |
return AnalysisResponse(
|
| 149 |
success=True,
|
| 150 |
message="Video description generated successfully",
|
| 151 |
+
video_description=enriched_description,
|
| 152 |
highlights=output_path,
|
| 153 |
analysis_file=analysis_path
|
| 154 |
)
|