Spaces:
Sleeping
Sleeping
Update main.py
Browse files
main.py
CHANGED
|
@@ -64,6 +64,19 @@ class DownloadRequest(BaseModel):
|
|
| 64 |
cookies_txt: Optional[str] = "" # optional – paste Netscape cookie text
|
| 65 |
|
| 66 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 67 |
@app.post("/download", summary="Start a video download job")
|
| 68 |
async def start_download(body: DownloadRequest):
|
| 69 |
"""
|
|
@@ -310,4 +323,4 @@ async def delete_job(job_id: str):
|
|
| 310 |
|
| 311 |
@app.get("/health")
|
| 312 |
async def health():
|
| 313 |
-
return {"status": "ok", "jobs": len(jobs)}
|
|
|
|
| 64 |
cookies_txt: Optional[str] = "" # optional – paste Netscape cookie text
|
| 65 |
|
| 66 |
|
| 67 |
+
@app.post("/download/shorts", summary="Start a YouTube Shorts download job")
|
| 68 |
+
async def download_shorts(body: DownloadRequest):
|
| 69 |
+
"""
|
| 70 |
+
نفس /download بالظبط، بس بيحوّل Shorts URL لـ watch URL الأول.
|
| 71 |
+
https://youtube.com/shorts/VIDEO_ID → https://youtube.com/watch?v=VIDEO_ID
|
| 72 |
+
"""
|
| 73 |
+
if "/shorts/" in body.url:
|
| 74 |
+
video_id = body.url.split("/shorts/")[1].split("?")[0]
|
| 75 |
+
body.url = f"https://www.youtube.com/watch?v={video_id}"
|
| 76 |
+
|
| 77 |
+
return await start_download(body)
|
| 78 |
+
|
| 79 |
+
|
| 80 |
@app.post("/download", summary="Start a video download job")
|
| 81 |
async def start_download(body: DownloadRequest):
|
| 82 |
"""
|
|
|
|
| 323 |
|
| 324 |
@app.get("/health")
|
| 325 |
async def health():
|
| 326 |
+
return {"status": "ok", "jobs": len(jobs)}
|