Update main.py
Browse files
main.py
CHANGED
|
@@ -268,6 +268,8 @@ async def tiktok_cdn(
|
|
| 268 |
|
| 269 |
raise HTTPException(status_code=400, detail="Provide either 'url' or 'token'")
|
| 270 |
|
|
|
|
|
|
|
| 271 |
@app.get("/api/v1/youtube/dl")
|
| 272 |
async def youtube_dl(
|
| 273 |
url: str = Query(...),
|
|
@@ -279,7 +281,25 @@ async def youtube_dl(
|
|
| 279 |
if not API_KEY or key != API_KEY:
|
| 280 |
raise HTTPException(status_code=403, detail="API key invalid")
|
| 281 |
|
| 282 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 283 |
|
| 284 |
@app.get("/api/v1/youtube/cdn")
|
| 285 |
async def youtube_cdn_proxy(
|
|
|
|
| 268 |
|
| 269 |
raise HTTPException(status_code=400, detail="Provide either 'url' or 'token'")
|
| 270 |
|
| 271 |
+
# Trong main.py
|
| 272 |
+
|
| 273 |
@app.get("/api/v1/youtube/dl")
|
| 274 |
async def youtube_dl(
|
| 275 |
url: str = Query(...),
|
|
|
|
| 281 |
if not API_KEY or key != API_KEY:
|
| 282 |
raise HTTPException(status_code=403, detail="API key invalid")
|
| 283 |
|
| 284 |
+
job_id = await yt_app.create_job(url, format, yt_cdn)
|
| 285 |
+
|
| 286 |
+
return {
|
| 287 |
+
"ok": True,
|
| 288 |
+
"message": "Job created. Please check status.",
|
| 289 |
+
"job_id": job_id,
|
| 290 |
+
"status_url": f"/api/v1/youtube/status?job_id={job_id}"
|
| 291 |
+
}
|
| 292 |
+
|
| 293 |
+
@app.get("/api/v1/youtube/status")
|
| 294 |
+
async def youtube_status(job_id: str = Query(...)):
|
| 295 |
+
job = yt_app.jobs.get(job_id)
|
| 296 |
+
if not job:
|
| 297 |
+
raise HTTPException(status_code=404, detail="Job not found")
|
| 298 |
+
|
| 299 |
+
return {
|
| 300 |
+
"ok": True,
|
| 301 |
+
"data": job
|
| 302 |
+
}
|
| 303 |
|
| 304 |
@app.get("/api/v1/youtube/cdn")
|
| 305 |
async def youtube_cdn_proxy(
|