Celeskry commited on
Commit
49dcb09
·
verified ·
1 Parent(s): 97ebe17

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +6 -8
main.py CHANGED
@@ -268,13 +268,11 @@ async def tiktok_cdn(
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(...),
276
- format: str = Query("1080"),
277
- apikey: Optional[str] = Query(None),
278
  x_api_key: Optional[str] = Header(None, alias="X-API-Key")
279
  ):
280
  key = x_api_key or apikey
@@ -282,10 +280,9 @@ async def youtube_dl(
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
  }
@@ -294,10 +291,11 @@ async def youtube_dl(
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
 
 
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(...),
274
+ format: str = Query("1080"),
275
+ apikey: Optional[str] = Query(None),
276
  x_api_key: Optional[str] = Header(None, alias="X-API-Key")
277
  ):
278
  key = x_api_key or apikey
 
280
  raise HTTPException(status_code=403, detail="API key invalid")
281
 
282
  job_id = await yt_app.create_job(url, format, yt_cdn)
 
283
  return {
284
  "ok": True,
285
+ "message": "Job created.",
286
  "job_id": job_id,
287
  "status_url": f"/api/v1/youtube/status?job_id={job_id}"
288
  }
 
291
  async def youtube_status(job_id: str = Query(...)):
292
  job = yt_app.jobs.get(job_id)
293
  if not job:
294
+ raise HTTPException(status_code=404, detail="Job not found or expired")
295
 
296
  return {
297
  "ok": True,
298
+ "meta": yt_app.meta_info,
299
  "data": job
300
  }
301