update
This commit is contained in:
@@ -48,16 +48,20 @@ 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),
|
||||
def delete_not_downloaded(db: Session, profile_id: int, exclude_ids: list[int] | None = None) -> int:
|
||||
query = db.query(Video).filter(
|
||||
Video.profiles.any(Profile.id == profile_id),
|
||||
).all()
|
||||
count = len(videos)
|
||||
for video in videos:
|
||||
db.delete(video)
|
||||
)
|
||||
if exclude_ids:
|
||||
query = query.filter(Video.id.notin_(exclude_ids))
|
||||
videos = query.all()
|
||||
video_ids = [v.id for v in videos]
|
||||
if not video_ids:
|
||||
return 0
|
||||
db.execute(video_profiles.delete().where(video_profiles.c.video_id.in_(video_ids)))
|
||||
db.query(Video).filter(Video.id.in_(video_ids)).delete(synchronize_session=False)
|
||||
db.commit()
|
||||
return count
|
||||
return len(video_ids)
|
||||
|
||||
|
||||
def get_all_profiles(db: Session) -> list[Profile]:
|
||||
|
||||
Reference in New Issue
Block a user