update
This commit is contained in:
@@ -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():
|
||||
|
||||
Reference in New Issue
Block a user