Добавил новые ЭП для новой версии загрузки видео с YouTube
This commit is contained in:
22
app/api/v2/endpoints/youtube.py
Normal file
22
app/api/v2/endpoints/youtube.py
Normal file
@@ -0,0 +1,22 @@
|
||||
from fastapi import APIRouter
|
||||
from app.schemas import TaskCreateResponse
|
||||
from app.schemas import DownloadRequest
|
||||
from app.tasks import download_youtube
|
||||
from app.services import YouTubeService
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
|
||||
@router.post("/download", response_model=TaskCreateResponse)
|
||||
async def download_video(data: DownloadRequest):
|
||||
task = download_youtube.delay(url=str(data.url), quality=data.quality)
|
||||
return TaskCreateResponse(task_id=task.id, status=task.status)
|
||||
|
||||
|
||||
@router.get("/resolutions")
|
||||
async def video_resolutions(url: str):
|
||||
return {"resolutions": YouTubeService.resolutions(url)}
|
||||
|
||||
@router.get("/size")
|
||||
async def video_size(data: DownloadRequest):
|
||||
return {"size": YouTubeService.filesize(data)}
|
||||
Reference in New Issue
Block a user