Добавил очередь

This commit is contained in:
Viner Abubakirov
2026-02-22 22:38:01 +05:00
parent 51ec17381f
commit a5c608674b
10 changed files with 277 additions and 9 deletions

16
app/tasks.py Normal file
View 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()