Добавил очередь
This commit is contained in:
16
app/tasks.py
Normal file
16
app/tasks.py
Normal file
@@ -0,0 +1,16 @@
|
||||
from app.core.celery import celery_app
|
||||
from app.services import YouTubeService
|
||||
from app.schemas import DownloadRequest
|
||||
|
||||
|
||||
@celery_app.task(
|
||||
bind=True,
|
||||
name="download_youtube",
|
||||
autoretry_for=(Exception,),
|
||||
retry_kwargs={"max_retries": 3},
|
||||
retry_backoff=True,
|
||||
)
|
||||
def download_youtube(self, url: str, quality: int) -> dict:
|
||||
request = DownloadRequest(url=url, quality=quality)
|
||||
response = YouTubeService.download(request)
|
||||
return response.model_dump()
|
||||
Reference in New Issue
Block a user