update
This commit is contained in:
Binary file not shown.
@@ -39,6 +39,12 @@ def get_downloaded_videos(profile_id: Optional[int] = Query(None), db: Session =
|
||||
return [VideoResponse.from_model(v) for v in videos]
|
||||
|
||||
|
||||
@router.delete("")
|
||||
def delete_not_downloaded(profile_id: int = Query(...), db: Session = Depends(get_db)):
|
||||
count = video_service.delete_not_downloaded(db, profile_id)
|
||||
return {"deleted": count}
|
||||
|
||||
|
||||
@router.post("/{video_id}/download")
|
||||
def trigger_download(video_id: int, db: Session = Depends(get_db)):
|
||||
video = video_service.get_video(db, video_id)
|
||||
|
||||
Binary file not shown.
@@ -48,5 +48,17 @@ def update_file_path(db: Session, video_id: int, path: str):
|
||||
db.commit()
|
||||
|
||||
|
||||
def delete_not_downloaded(db: Session, profile_id: int) -> int:
|
||||
videos = db.query(Video).filter(
|
||||
Video.file_path.is_(None),
|
||||
Video.profiles.any(Profile.id == profile_id),
|
||||
).all()
|
||||
count = len(videos)
|
||||
for video in videos:
|
||||
db.delete(video)
|
||||
db.commit()
|
||||
return count
|
||||
|
||||
|
||||
def get_all_profiles(db: Session) -> list[Profile]:
|
||||
return db.query(Profile).all()
|
||||
|
||||
Reference in New Issue
Block a user