@@ -125,6 +125,32 @@ def get_video_or_all(collection_id, video_id):
125125 return videodb .get_video (video_id )
126126 else :
127127 return videodb .get_videos ()
128+
129+ @videodb_bp .route (
130+ "/collection/<collection_id>/audio" , defaults = {"audio_id" : None }, methods = ["GET" ]
131+ )
132+ @videodb_bp .route ("/collection/<collection_id>/audio/<audio_id>" , methods = ["GET" ])
133+ def get_audio_or_all (collection_id , audio_id , ** kwargs ):
134+ """Get a video by ID or all videos in a collection."""
135+ videodb = VideoDBHandler (collection_id )
136+ if audio_id :
137+ return videodb .get_audio (audio_id )
138+ else :
139+ return videodb .get_audios ()
140+
141+
142+ @videodb_bp .route (
143+ "/collection/<collection_id>/image" , defaults = {"image_id" : None }, methods = ["GET" ]
144+ )
145+ @videodb_bp .route ("/collection/<collection_id>/image/<image_id>" , methods = ["GET" ])
146+ def get_image_or_all (collection_id , image_id , ** kwargs ):
147+ """Get a video by ID or all videos in a collection."""
148+ videodb = VideoDBHandler (collection_id )
149+ if image_id :
150+ return videodb .get_image (image_id )
151+ else :
152+ return videodb .get_images ()
153+
128154
129155
130156@videodb_bp .route ("/collection/<collection_id>/video/<video_id>" , methods = ["DELETE" ])
@@ -140,6 +166,32 @@ def delete_video(collection_id, video_id):
140166 return {"message" : str (e )}, 500
141167
142168
169+ @videodb_bp .route ("/collection/<collection_id>/audio/<audio_id>" , methods = ["DELETE" ])
170+ def delete_audio (collection_id , audio_id ):
171+ """Delete a audio by ID from a specific collection."""
172+ try :
173+ if not audio_id :
174+ return {"message" : "Video ID is required" }, 400
175+ videodb = VideoDBHandler (collection_id )
176+ result = videodb .delete_audio (audio_id )
177+ return result , 200
178+ except Exception as e :
179+ return {"message" : str (e )}, 500
180+
181+
182+ @videodb_bp .route ("/collection/<collection_id>/image/<image_id>" , methods = ["DELETE" ])
183+ def delete_image (collection_id , image_id ):
184+ """Delete a image by ID from a specific collection."""
185+ try :
186+ if not image_id :
187+ return {"message" : "Video ID is required" }, 400
188+ videodb = VideoDBHandler (collection_id )
189+ result = videodb .delete_image (image_id )
190+ return result , 200
191+ except Exception as e :
192+ return {"message" : str (e )}, 500
193+
194+
143195@videodb_bp .route (
144196 "/collection/<collection_id>/image/<image_id>/generate_url" , methods = ["GET" ]
145197)
@@ -157,6 +209,22 @@ def generate_image_url(collection_id, image_id):
157209 except Exception as e :
158210 return {"message" : str (e )}, 500
159211
212+ @videodb_bp .route (
213+ "/collection/<collection_id>/audio/<audio_id>/generate_url" , methods = ["GET" ]
214+ )
215+ def generate_audio_url (collection_id , audio_id ):
216+ try :
217+ if not collection_id :
218+ return {"message" : "Collection ID is required" }, 400
219+
220+ if not audio_id :
221+ return {"message" : "Audio ID is required" }, 400
222+
223+ videodb = VideoDBHandler (collection_id )
224+ result = videodb .generate_audio_url (audio_id )
225+ return result , 200
226+ except Exception as e :
227+ return {"message" : str (e )}, 500
160228
161229@videodb_bp .route ("/collection/<collection_id>/upload" , methods = ["POST" ])
162230def upload_video (collection_id ):
0 commit comments