Update storage/pending_videos_routers.py
Browse files
storage/pending_videos_routers.py
CHANGED
|
@@ -48,7 +48,36 @@ def clear_media(token: str = Query(..., description="Token required for authoriz
|
|
| 48 |
return {"status": "ok", "message": "All peding_videos files deleted successfully"}
|
| 49 |
|
| 50 |
|
| 51 |
-
@router.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 52 |
async def upload_video(
|
| 53 |
video: UploadFile = File(...),
|
| 54 |
token: str = Query(..., description="Token required for authorization")
|
|
@@ -107,7 +136,7 @@ async def upload_video(
|
|
| 107 |
)
|
| 108 |
|
| 109 |
|
| 110 |
-
@router.get("/
|
| 111 |
def download_video(
|
| 112 |
sha1: str,
|
| 113 |
token: str = Query(..., description="Token required for authorization")
|
|
@@ -166,7 +195,7 @@ def download_video(
|
|
| 166 |
filename=video_path.name
|
| 167 |
)
|
| 168 |
|
| 169 |
-
@router.get("/
|
| 170 |
def list_all_videos(
|
| 171 |
token: str = Query(..., description="Token required for authorization")
|
| 172 |
):
|
|
|
|
| 48 |
return {"status": "ok", "message": "All peding_videos files deleted successfully"}
|
| 49 |
|
| 50 |
|
| 51 |
+
@router.delete("/clear_pending_video", tags=["Pending Videos Manager"])
|
| 52 |
+
def clear_pending_video(
|
| 53 |
+
sha1: str = Query(..., description="SHA1 folder to delete inside pending_videos"),
|
| 54 |
+
token: str = Query(..., description="Token required for authorization")
|
| 55 |
+
):
|
| 56 |
+
"""
|
| 57 |
+
Delete a specific SHA1 folder inside /data/pending_videos.
|
| 58 |
+
Steps:
|
| 59 |
+
- Validate the token.
|
| 60 |
+
- Ensure the folder exists.
|
| 61 |
+
- Delete the folder and all its contents.
|
| 62 |
+
- Return a JSON response confirming the deletion.
|
| 63 |
+
"""
|
| 64 |
+
validate_token(token)
|
| 65 |
+
|
| 66 |
+
PENDING_ROOT = Path("/data/pending_videos")
|
| 67 |
+
target_folder = PENDING_ROOT / sha1
|
| 68 |
+
|
| 69 |
+
if not target_folder.exists() or not target_folder.is_dir():
|
| 70 |
+
raise HTTPException(status_code=404, detail=f"Folder {sha1} does not exist in pending_videos")
|
| 71 |
+
|
| 72 |
+
try:
|
| 73 |
+
shutil.rmtree(target_folder)
|
| 74 |
+
except Exception as e:
|
| 75 |
+
raise HTTPException(status_code=500, detail=f"Failed to delete {sha1}: {e}")
|
| 76 |
+
|
| 77 |
+
return {"status": "ok", "message": f"Pending video folder {sha1} deleted successfully"}
|
| 78 |
+
|
| 79 |
+
|
| 80 |
+
@router.post("/upload_pending_video", tags=["Pending Videos Manager"])
|
| 81 |
async def upload_video(
|
| 82 |
video: UploadFile = File(...),
|
| 83 |
token: str = Query(..., description="Token required for authorization")
|
|
|
|
| 136 |
)
|
| 137 |
|
| 138 |
|
| 139 |
+
@router.get("/download_pending_video", tags=["Pending Videos Manager"])
|
| 140 |
def download_video(
|
| 141 |
sha1: str,
|
| 142 |
token: str = Query(..., description="Token required for authorization")
|
|
|
|
| 195 |
filename=video_path.name
|
| 196 |
)
|
| 197 |
|
| 198 |
+
@router.get("/list_pending_videos", tags=["Pending Videos Manager"])
|
| 199 |
def list_all_videos(
|
| 200 |
token: str = Query(..., description="Token required for authorization")
|
| 201 |
):
|