@@ -49,6 +49,7 @@ def search(
4949 self ,
5050 query : str ,
5151 search_type : Optional [str ] = SearchType .semantic ,
52+ index_type : Optional [str ] = IndexType .spoken_word ,
5253 result_threshold : Optional [int ] = None ,
5354 score_threshold : Optional [float ] = None ,
5455 dynamic_score_percentage : Optional [float ] = None ,
@@ -58,6 +59,8 @@ def search(
5859 return search .search_inside_video (
5960 video_id = self .id ,
6061 query = query ,
62+ search_type = search_type ,
63+ index_type = index_type ,
6164 result_threshold = result_threshold ,
6265 score_threshold = score_threshold ,
6366 dynamic_score_percentage = dynamic_score_percentage ,
@@ -152,7 +155,7 @@ def index_spoken_words(
152155 self ._connection .post (
153156 path = f"{ ApiPath .video } /{ self .id } /{ ApiPath .index } " ,
154157 data = {
155- "index_type" : IndexType .semantic ,
158+ "index_type" : IndexType .spoken_word ,
156159 "language_code" : language_code ,
157160 "force" : force ,
158161 "callback_url" : callback_url ,
@@ -194,6 +197,7 @@ def _format_scene_collection(self, scene_collection_data: dict) -> SceneCollecti
194197 description = scene .get ("description" ),
195198 id = scene .get ("scene_id" ),
196199 frames = frames ,
200+ connection = self ._connection ,
197201 )
198202 scenes .append (scene )
199203
@@ -207,11 +211,11 @@ def _format_scene_collection(self, scene_collection_data: dict) -> SceneCollecti
207211
208212 def extract_scenes (
209213 self ,
210- extraction_type : SceneExtractionType = SceneExtractionType .scene_based ,
214+ extraction_type : SceneExtractionType = SceneExtractionType .shot_based ,
211215 extraction_config : dict = {},
212216 force : bool = False ,
213217 callback_url : str = None ,
214- ):
218+ ) -> Optional [ SceneCollection ] :
215219 scenes_data = self ._connection .post (
216220 path = f"{ ApiPath .video } /{ self .id } /{ ApiPath .scenes } " ,
217221 data = {
@@ -225,10 +229,14 @@ def extract_scenes(
225229 return None
226230 return self ._format_scene_collection (scenes_data .get ("scene_collection" ))
227231
228- def get_scene_collection (self , collection_id : str ):
232+ def get_scene_collection (self , collection_id : str ) -> Optional [SceneCollection ]:
233+ if not collection_id :
234+ raise ValueError ("collection_id is required" )
229235 scenes_data = self ._connection .get (
230236 path = f"{ ApiPath .video } /{ self .id } /{ ApiPath .scenes } /{ collection_id } "
231237 )
238+ if not scenes_data :
239+ return None
232240 return self ._format_scene_collection (scenes_data .get ("scene_collection" ))
233241
234242 def list_scene_collection (self ):
@@ -238,29 +246,31 @@ def list_scene_collection(self):
238246 return scene_collections_data .get ("scene_collections" , [])
239247
240248 def delete_scene_collection (self , collection_id : str ) -> None :
249+ if not collection_id :
250+ raise ValueError ("collection_id is required" )
241251 self ._connection .delete (
242252 path = f"{ ApiPath .video } /{ self .id } /{ ApiPath .scenes } /{ collection_id } "
243253 )
244254
245255 def index_scenes (
246256 self ,
247- extraction_type : SceneExtractionType = SceneExtractionType .scene_based ,
257+ extraction_type : SceneExtractionType = SceneExtractionType .shot_based ,
248258 extraction_config : Dict = {},
249259 prompt : Optional [str ] = None ,
250- model : Optional [str ] = None ,
260+ model_name : Optional [str ] = None ,
251261 model_config : Optional [Dict ] = None ,
252262 name : Optional [str ] = None ,
253263 scenes : Optional [List [Scene ]] = None ,
254264 force : Optional [bool ] = False ,
255265 callback_url : Optional [str ] = None ,
256- ) -> Optional [List ]:
266+ ) -> Optional [str ]:
257267 scenes_data = self ._connection .post (
258268 path = f"{ ApiPath .video } /{ self .id } /{ ApiPath .index } /{ ApiPath .scene } " ,
259269 data = {
260270 "extraction_type" : extraction_type ,
261271 "extraction_config" : extraction_config ,
262272 "prompt" : prompt ,
263- "model " : model ,
273+ "model_name " : model_name ,
264274 "model_config" : model_config ,
265275 "name" : name ,
266276 "force" : force ,
@@ -270,7 +280,7 @@ def index_scenes(
270280 )
271281 if not scenes_data :
272282 return None
273- return scenes_data .get ("scene_index_records" , [] )
283+ return scenes_data .get ("scene_index_id" )
274284
275285 def list_scene_index (self ) -> List :
276286 index_data = self ._connection .get (
@@ -287,6 +297,8 @@ def get_scene_index(self, scene_index_id: str) -> Optional[List]:
287297 return index_data .get ("scene_index_records" , [])
288298
289299 def delete_scene_index (self , scene_index_id : str ) -> None :
300+ if not scene_index_id :
301+ raise ValueError ("scene_index_id is required" )
290302 self ._connection .delete (
291303 path = f"{ ApiPath .video } /{ self .id } /{ ApiPath .index } /{ ApiPath .scene } /{ scene_index_id } "
292304 )
0 commit comments