1313)
1414from videodb .video import Video
1515from videodb .audio import Audio
16+ from videodb .image import Image
1617from videodb .search import SearchFactory , SearchResult
1718
1819logger = logging .getLogger (__name__ )
@@ -54,6 +55,17 @@ def get_audio(self, audio_id: str) -> Audio:
5455 def delete_audio (self , audio_id : str ) -> None :
5556 return self ._connection .delete (path = f"{ ApiPath .audio } /{ audio_id } " )
5657
58+ def get_images (self ) -> list [Image ]:
59+ images_data = self ._connection .get (path = f"{ ApiPath .image } " )
60+ return [Image (self ._connection , ** image ) for image in images_data .get ("images" )]
61+
62+ def get_image (self , image_id : str ) -> Image :
63+ image_data = self ._connection .get (path = f"{ ApiPath .image } /{ image_id } " )
64+ return Image (self ._connection , ** image_data )
65+
66+ def delete_image (self , image_id : str ) -> None :
67+ return self ._connection .delete (path = f"{ ApiPath .image } /{ image_id } " )
68+
5769 def search (
5870 self ,
5971 query : str ,
@@ -79,7 +91,7 @@ def upload(
7991 name : Optional [str ] = None ,
8092 description : Optional [str ] = None ,
8193 callback_url : Optional [str ] = None ,
82- ) -> Union [Video , Audio , None ]:
94+ ) -> Union [Video , Audio , Image , None ]:
8395 upload_data = upload (
8496 self ._connection ,
8597 file_path ,
@@ -89,7 +101,10 @@ def upload(
89101 description ,
90102 callback_url ,
91103 )
92- if upload_data .get ("id" ).startswith ("m-" ):
93- return Video (self ._connection , ** upload_data ) if upload_data else None
94- elif upload_data .get ("id" ).startswith ("a-" ):
95- return Audio (self ._connection , ** upload_data ) if upload_data else None
104+ media_id = upload_data .get ("id" , "" )
105+ if media_id .startswith ("m-" ):
106+ return Video (self , ** upload_data )
107+ elif media_id .startswith ("a-" ):
108+ return Audio (self , ** upload_data )
109+ elif media_id .startswith ("img-" ):
110+ return Image (self , ** upload_data )
0 commit comments