Commit ·
73120a1
1
Parent(s): 00db48c
fix list_save endpoint
Browse files- routers/video.py +54 -3
routers/video.py
CHANGED
|
@@ -300,11 +300,62 @@ async def process_video(
|
|
| 300 |
if isinstance(e, HTTPException): raise e
|
| 301 |
return JSONResponse(status_code=500, content={"error": str(e)})
|
| 302 |
|
| 303 |
-
@router.get("/
|
| 304 |
-
async def
|
| 305 |
"""
|
| 306 |
-
|
| 307 |
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 308 |
try:
|
| 309 |
# Get disk usage
|
| 310 |
total, used, free = shutil.disk_usage("/")
|
|
|
|
| 300 |
if isinstance(e, HTTPException): raise e
|
| 301 |
return JSONResponse(status_code=500, content={"error": str(e)})
|
| 302 |
|
| 303 |
+
@router.get("/list-saved", tags=["Video"])
|
| 304 |
+
async def list_saved_files():
|
| 305 |
"""
|
| 306 |
+
List all files in temp, processed (main), and originals folders.
|
| 307 |
"""
|
| 308 |
+
try:
|
| 309 |
+
files_data = {
|
| 310 |
+
"temp": [],
|
| 311 |
+
"processed": [],
|
| 312 |
+
"originals": []
|
| 313 |
+
}
|
| 314 |
+
|
| 315 |
+
# Check temp folder
|
| 316 |
+
if os.path.exists(TEMP_DIR):
|
| 317 |
+
for filename in os.listdir(TEMP_DIR):
|
| 318 |
+
file_path = os.path.join(TEMP_DIR, filename)
|
| 319 |
+
if os.path.isfile(file_path):
|
| 320 |
+
files_data["temp"].append({
|
| 321 |
+
"filename": filename,
|
| 322 |
+
"size_mb": round(os.path.getsize(file_path) / (1024 * 1024), 2),
|
| 323 |
+
"created": os.path.getctime(file_path)
|
| 324 |
+
})
|
| 325 |
+
|
| 326 |
+
# Check processed (main) folder
|
| 327 |
+
if os.path.exists(PROCESSED_DIR):
|
| 328 |
+
for filename in os.listdir(PROCESSED_DIR):
|
| 329 |
+
file_path = os.path.join(PROCESSED_DIR, filename)
|
| 330 |
+
if os.path.isfile(file_path):
|
| 331 |
+
files_data["processed"].append({
|
| 332 |
+
"filename": filename,
|
| 333 |
+
"size_mb": round(os.path.getsize(file_path) / (1024 * 1024), 2),
|
| 334 |
+
"created": os.path.getctime(file_path)
|
| 335 |
+
})
|
| 336 |
+
|
| 337 |
+
# Check originals folder
|
| 338 |
+
if os.path.exists(ORIGINALS_DIR):
|
| 339 |
+
for filename in os.listdir(ORIGINALS_DIR):
|
| 340 |
+
file_path = os.path.join(ORIGINALS_DIR, filename)
|
| 341 |
+
if os.path.isfile(file_path):
|
| 342 |
+
files_data["originals"].append({
|
| 343 |
+
"filename": filename,
|
| 344 |
+
"size_mb": round(os.path.getsize(file_path) / (1024 * 1024), 2),
|
| 345 |
+
"created": os.path.getctime(file_path)
|
| 346 |
+
})
|
| 347 |
+
|
| 348 |
+
return {
|
| 349 |
+
"status": "success",
|
| 350 |
+
"counts": {
|
| 351 |
+
"temp": len(files_data["temp"]),
|
| 352 |
+
"processed": len(files_data["processed"]),
|
| 353 |
+
"originals": len(files_data["originals"])
|
| 354 |
+
},
|
| 355 |
+
"files": files_data
|
| 356 |
+
}
|
| 357 |
+
except Exception as e:
|
| 358 |
+
return JSONResponse(status_code=500, content={"error": f"Failed to list files: {str(e)}"})
|
| 359 |
try:
|
| 360 |
# Get disk usage
|
| 361 |
total, used, free = shutil.disk_usage("/")
|