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