This commit is contained in:
Marek
2026-04-05 14:54:10 +02:00
parent 7d66746969
commit 6bbadb69c7
11 changed files with 129 additions and 147 deletions

View File

@@ -13,17 +13,22 @@ def create_video(db: Session, video_data: VideoCreate) -> Video:
def get_all_videos(db: Session) -> list[Video]:
return db.query(Video).order_by(Video.created_at.desc()).all()
return db.query(Video).order_by(Video.id.desc()).all()
def get_downloaded_videos(db: Session) -> list[Video]:
return db.query(Video).filter(Video.file_path.isnot(None)).order_by(Video.created_at.desc()).all()
return db.query(Video).filter(Video.file_path.isnot(None)).order_by(Video.id.desc()).all()
def get_video(db: Session, video_id: int) -> Video | None:
return db.query(Video).filter(Video.id == video_id).first()
def delete_by_youtube_id(db: Session, youtube_id: str):
db.query(Video).filter(Video.youtube_url.contains(youtube_id)).delete(synchronize_session=False)
db.commit()
def update_file_path(db: Session, video_id: int, path: str):
video = get_video(db, video_id)
if video: