Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -482,19 +482,24 @@ async def upload_file(
|
|
482 |
except Exception as e:
|
483 |
raise HTTPException(status_code=500, detail=f"Upload failed: {str(e)}")
|
484 |
|
485 |
-
@app.get("/list-
|
486 |
-
async def
|
487 |
try:
|
488 |
-
#
|
489 |
files = api.list_repo_files(repo_id=DATASET_REPO, repo_type="dataset", token=HF_TOKEN)
|
490 |
|
491 |
-
#
|
492 |
-
|
|
|
493 |
|
494 |
-
|
|
|
|
|
|
|
495 |
|
496 |
except Exception as e:
|
497 |
-
raise HTTPException(status_code=500, detail=f"Failed to fetch
|
|
|
498 |
|
499 |
|
500 |
|
|
|
482 |
except Exception as e:
|
483 |
raise HTTPException(status_code=500, detail=f"Upload failed: {str(e)}")
|
484 |
|
485 |
+
@app.get("/list-videos/")
|
486 |
+
async def list_videos():
|
487 |
try:
|
488 |
+
# Récupérer la liste des fichiers du dataset
|
489 |
files = api.list_repo_files(repo_id=DATASET_REPO, repo_type="dataset", token=HF_TOKEN)
|
490 |
|
491 |
+
# Filtrer les fichiers pour ne garder que les vidéos (par exemple .mp4, .avi, .mov)
|
492 |
+
video_extensions = [".mp4", ".avi", ".mov", ".mkv", ".flv"] # Ajouter d'autres extensions si nécessaire
|
493 |
+
video_files = [f for f in files if any(f.endswith(ext) for ext in video_extensions)]
|
494 |
|
495 |
+
# Formater en JSON avec URLs complètes
|
496 |
+
videos_list = [{"file_name": f, "url": f"https://huggingface.co/datasets/{DATASET_REPO}/blob/main/{f}"} for f in video_files]
|
497 |
+
|
498 |
+
return {"status": "success", "videos": videos_list}
|
499 |
|
500 |
except Exception as e:
|
501 |
+
raise HTTPException(status_code=500, detail=f"Failed to fetch videos: {str(e)}")
|
502 |
+
|
503 |
|
504 |
|
505 |
|