This commit is contained in:
Marek Lenczewski
2026-04-15 21:53:37 +02:00
parent 2156bb3226
commit 1cef5fa1e8
18 changed files with 154 additions and 71 deletions

View File

@@ -12,25 +12,25 @@ router = APIRouter(prefix="/videos")
@router.post("/{videoId}/download")
def download(videoId: int, db: DbSession):
def download(videoId: int, db: DbSession, maxHeight: int = 1080):
video = Video.getById(db, videoId)
if not video:
raise HTTPException(404, "Video nicht gefunden")
if video.filePath:
return {"status": "already_downloaded"}
downloadAsync(videoId, video.youtubeUrl)
downloadAsync(videoId, video.youtubeUrl, maxHeight)
return {"status": "download_started"}
@router.get("/{videoId}/stream")
def stream(videoId: int, db: DbSession):
def stream(videoId: int, db: DbSession, maxHeight: int = 1080):
video = Video.getById(db, videoId)
if not video:
raise HTTPException(404, "Video nicht gefunden")
if not video.filePath:
return StreamingResponse(streamAndSave(videoId, video.youtubeUrl), media_type="video/mp4")
return StreamingResponse(streamAndSave(videoId, video.youtubeUrl, maxHeight), media_type="video/mp4")
path = Path(video.filePath)
if not path.exists():