@@ -49,6 +49,7 @@ def search(
49
49
self ,
50
50
query : str ,
51
51
search_type : Optional [str ] = SearchType .semantic ,
52
+ index_type : Optional [str ] = IndexType .spoken_word ,
52
53
result_threshold : Optional [int ] = None ,
53
54
score_threshold : Optional [float ] = None ,
54
55
dynamic_score_percentage : Optional [float ] = None ,
@@ -58,6 +59,8 @@ def search(
58
59
return search .search_inside_video (
59
60
video_id = self .id ,
60
61
query = query ,
62
+ search_type = search_type ,
63
+ index_type = index_type ,
61
64
result_threshold = result_threshold ,
62
65
score_threshold = score_threshold ,
63
66
dynamic_score_percentage = dynamic_score_percentage ,
@@ -152,7 +155,7 @@ def index_spoken_words(
152
155
self ._connection .post (
153
156
path = f"{ ApiPath .video } /{ self .id } /{ ApiPath .index } " ,
154
157
data = {
155
- "index_type" : IndexType .semantic ,
158
+ "index_type" : IndexType .spoken_word ,
156
159
"language_code" : language_code ,
157
160
"force" : force ,
158
161
"callback_url" : callback_url ,
@@ -194,6 +197,7 @@ def _format_scene_collection(self, scene_collection_data: dict) -> SceneCollecti
194
197
description = scene .get ("description" ),
195
198
id = scene .get ("scene_id" ),
196
199
frames = frames ,
200
+ connection = self ._connection ,
197
201
)
198
202
scenes .append (scene )
199
203
@@ -207,11 +211,11 @@ def _format_scene_collection(self, scene_collection_data: dict) -> SceneCollecti
207
211
208
212
def extract_scenes (
209
213
self ,
210
- extraction_type : SceneExtractionType = SceneExtractionType .scene_based ,
214
+ extraction_type : SceneExtractionType = SceneExtractionType .shot_based ,
211
215
extraction_config : dict = {},
212
216
force : bool = False ,
213
217
callback_url : str = None ,
214
- ):
218
+ ) -> Optional [ SceneCollection ] :
215
219
scenes_data = self ._connection .post (
216
220
path = f"{ ApiPath .video } /{ self .id } /{ ApiPath .scenes } " ,
217
221
data = {
@@ -225,10 +229,14 @@ def extract_scenes(
225
229
return None
226
230
return self ._format_scene_collection (scenes_data .get ("scene_collection" ))
227
231
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" )
229
235
scenes_data = self ._connection .get (
230
236
path = f"{ ApiPath .video } /{ self .id } /{ ApiPath .scenes } /{ collection_id } "
231
237
)
238
+ if not scenes_data :
239
+ return None
232
240
return self ._format_scene_collection (scenes_data .get ("scene_collection" ))
233
241
234
242
def list_scene_collection (self ):
@@ -238,29 +246,31 @@ def list_scene_collection(self):
238
246
return scene_collections_data .get ("scene_collections" , [])
239
247
240
248
def delete_scene_collection (self , collection_id : str ) -> None :
249
+ if not collection_id :
250
+ raise ValueError ("collection_id is required" )
241
251
self ._connection .delete (
242
252
path = f"{ ApiPath .video } /{ self .id } /{ ApiPath .scenes } /{ collection_id } "
243
253
)
244
254
245
255
def index_scenes (
246
256
self ,
247
- extraction_type : SceneExtractionType = SceneExtractionType .scene_based ,
257
+ extraction_type : SceneExtractionType = SceneExtractionType .shot_based ,
248
258
extraction_config : Dict = {},
249
259
prompt : Optional [str ] = None ,
250
- model : Optional [str ] = None ,
260
+ model_name : Optional [str ] = None ,
251
261
model_config : Optional [Dict ] = None ,
252
262
name : Optional [str ] = None ,
253
263
scenes : Optional [List [Scene ]] = None ,
254
264
force : Optional [bool ] = False ,
255
265
callback_url : Optional [str ] = None ,
256
- ) -> Optional [List ]:
266
+ ) -> Optional [str ]:
257
267
scenes_data = self ._connection .post (
258
268
path = f"{ ApiPath .video } /{ self .id } /{ ApiPath .index } /{ ApiPath .scene } " ,
259
269
data = {
260
270
"extraction_type" : extraction_type ,
261
271
"extraction_config" : extraction_config ,
262
272
"prompt" : prompt ,
263
- "model " : model ,
273
+ "model_name " : model_name ,
264
274
"model_config" : model_config ,
265
275
"name" : name ,
266
276
"force" : force ,
@@ -270,7 +280,7 @@ def index_scenes(
270
280
)
271
281
if not scenes_data :
272
282
return None
273
- return scenes_data .get ("scene_index_records" , [] )
283
+ return scenes_data .get ("scene_index_id" )
274
284
275
285
def list_scene_index (self ) -> List :
276
286
index_data = self ._connection .get (
@@ -287,6 +297,8 @@ def get_scene_index(self, scene_index_id: str) -> Optional[List]:
287
297
return index_data .get ("scene_index_records" , [])
288
298
289
299
def delete_scene_index (self , scene_index_id : str ) -> None :
300
+ if not scene_index_id :
301
+ raise ValueError ("scene_index_id is required" )
290
302
self ._connection .delete (
291
303
path = f"{ ApiPath .video } /{ self .id } /{ ApiPath .index } /{ ApiPath .scene } /{ scene_index_id } "
292
304
)
0 commit comments