Skip to content

Commit 7d26a40

Browse files
authored
python sdk v0.3.4 (#31)
changes - pull latest api spec and regenerate low level sdk - expose file liter for list collection files - expose pagination options for describe / get media descriptions, and extract - expose options for enabling audio description in describe based operations - bump package version
1 parent dbb37cd commit 7d26a40

File tree

154 files changed

+937
-575
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

154 files changed

+937
-575
lines changed

cloudglue/client/resources.py

Lines changed: 54 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -583,6 +583,7 @@ def list_videos(
583583
added_after: Optional[str] = None,
584584
order: Optional[str] = None,
585585
sort: Optional[str] = None,
586+
filter: Optional[Union[SearchFilter, Dict[str, Any]]] = None,
586587
):
587588
"""List videos in a collection.
588589
@@ -595,14 +596,24 @@ def list_videos(
595596
added_after: Filter by videos added after a specific date, YYYY-MM-DD format in UTC
596597
order: Field to sort by ('created_at'). Defaults to 'created_at'
597598
sort: Sort direction ('asc', 'desc'). Defaults to 'desc'
598-
599+
filter: Optional filter object or dictionary for advanced filtering by metadata, video info, or file properties.
600+
Use Files.create_filter() to create filter objects.
599601
Returns:
600602
The typed CollectionFileList object with videos and metadata
601603
602604
Raises:
603605
CloudGlueError: If there is an error listing the videos or processing the request.
604606
"""
605607
try:
608+
# Convert filter dict to SearchFilter object if needed
609+
filter_obj = None
610+
if filter is not None:
611+
if isinstance(filter, dict):
612+
# Convert dict to SearchFilter object
613+
filter_obj = SearchFilter(**filter)
614+
else:
615+
filter_obj = filter
616+
606617
# Use the standard method to get a properly typed object
607618
response = self.api.list_videos(
608619
collection_id=collection_id,
@@ -613,6 +624,7 @@ def list_videos(
613624
added_after=added_after,
614625
order=order,
615626
sort=sort,
627+
filter=json.dumps(filter_obj.to_dict()) if filter_obj else None,
616628
)
617629
return response
618630
except ApiException as e:
@@ -648,13 +660,17 @@ def get_rich_transcripts(
648660
self,
649661
collection_id: str,
650662
file_id: str,
663+
start_time_seconds: Optional[float] = None,
664+
end_time_seconds: Optional[float] = None,
651665
response_format: Optional[str] = None,
652666
):
653667
"""Get the rich transcript of a video in a collection.
654668
655669
Args:
656670
collection_id: The ID of the collection
657671
file_id: The ID of the file to retrieve the rich transcript for
672+
start_time_seconds: The start time in seconds to filter the rich transcript
673+
end_time_seconds: The end time in seconds to filter the rich transcript
658674
response_format: The format of the response, one of 'json' or 'markdown' (json by default)
659675
660676
Returns:
@@ -666,7 +682,7 @@ def get_rich_transcripts(
666682
try:
667683
# Use the standard method to get a properly typed object
668684
response = self.api.get_transcripts(
669-
collection_id=collection_id, file_id=file_id, response_format=response_format
685+
collection_id=collection_id, file_id=file_id, start_time_seconds=start_time_seconds, end_time_seconds=end_time_seconds, response_format=response_format
670686
)
671687
return response
672688
except ApiException as e:
@@ -810,13 +826,17 @@ def get_media_descriptions(
810826
self,
811827
collection_id: str,
812828
file_id: str,
829+
start_time_seconds: Optional[float] = None,
830+
end_time_seconds: Optional[float] = None,
813831
response_format: Optional[str] = None,
814832
):
815833
"""Get the media descriptions of a video in a collection.
816834
817835
Args:
818836
collection_id: The ID of the collection
819837
file_id: The ID of the file to retrieve the media descriptions for
838+
start_time_seconds: The start time in seconds to filter the media descriptions
839+
end_time_seconds: The end time in seconds to filter the media descriptions
820840
response_format: The format of the response, one of 'json' or 'markdown' (json by default)
821841
822842
Returns:
@@ -828,7 +848,7 @@ def get_media_descriptions(
828848
try:
829849
# Use the standard method to get a properly typed object
830850
response = self.api.get_media_descriptions(
831-
collection_id=collection_id, file_id=file_id, response_format=response_format
851+
collection_id=collection_id, file_id=file_id, start_time_seconds=start_time_seconds, end_time_seconds=end_time_seconds, response_format=response_format
832852
)
833853
return response
834854
except ApiException as e:
@@ -966,20 +986,26 @@ def create(
966986
except Exception as e:
967987
raise CloudGlueError(str(e))
968988

969-
def get(self, job_id: str):
989+
def get(
990+
self,
991+
job_id: str,
992+
limit: Optional[int] = None,
993+
offset: Optional[int] = None,
994+
):
970995
"""Get the status of an extraction job.
971996
972997
Args:
973998
job_id: The ID of the extraction job.
974-
999+
limit: Maximum number of segment entities to return (1-100)
1000+
offset: Number of segment entities to skip
9751001
Returns:
9761002
Extract: A typed Extract object containing the job status and extracted data if available.
9771003
9781004
Raises:
9791005
CloudGlueError: If there is an error retrieving the extraction job or processing the request.
9801006
"""
9811007
try:
982-
response = self.api.get_extract(job_id=job_id)
1008+
response = self.api.get_extract(job_id=job_id, limit=limit, offset=offset)
9831009
return response
9841010
except ApiException as e:
9851011
raise CloudGlueError(str(e), e.status, e.data, e.headers, e.reason)
@@ -1105,6 +1131,7 @@ def create(
11051131
enable_speech: bool = True,
11061132
enable_scene_text: bool = False,
11071133
enable_visual_scene_description: bool = False,
1134+
enable_audio_description: bool = False,
11081135
segmentation_id: Optional[str] = None,
11091136
segmentation_config: Optional[Union[SegmentationConfig, Dict[str, Any]]] = None,
11101137
thumbnails_config: Optional[Union[Dict[str, Any], Any]] = None,
@@ -1117,6 +1144,7 @@ def create(
11171144
enable_speech: Whether to generate speech transcript.
11181145
enable_scene_text: Whether to generate scene text.
11191146
enable_visual_scene_description: Whether to generate visual scene description.
1147+
enable_audio_description: Whether to generate audio description.
11201148
segmentation_id: Segmentation job id to use. Cannot be provided together with segmentation_config.
11211149
segmentation_config: Configuration for video segmentation. Cannot be provided together with segmentation_id.
11221150
thumbnails_config: Optional configuration for segment thumbnails
@@ -1149,6 +1177,7 @@ def create(
11491177
enable_speech=enable_speech,
11501178
enable_scene_text=enable_scene_text,
11511179
enable_visual_scene_description=enable_visual_scene_description,
1180+
enable_audio_description=enable_audio_description,
11521181
segmentation_id=segmentation_id,
11531182
segmentation_config=segmentation_config,
11541183
thumbnails_config=thumbnails_config_obj,
@@ -1236,6 +1265,7 @@ def run(
12361265
enable_speech: bool = True,
12371266
enable_scene_text: bool = False,
12381267
enable_visual_scene_description: bool = False,
1268+
enable_audio_description: bool = False,
12391269
segmentation_id: Optional[str] = None,
12401270
segmentation_config: Optional[Union[SegmentationConfig, Dict[str, Any]]] = None,
12411271
thumbnails_config: Optional[Union[Dict[str, Any], Any]] = None,
@@ -1251,6 +1281,7 @@ def run(
12511281
enable_speech: Whether to generate speech transcript.
12521282
enable_scene_text: Whether to generate scene text.
12531283
enable_visual_scene_description: Whether to generate visual scene description.
1284+
enable_audio_description: Whether to generate audio description.
12541285
segmentation_id: Segmentation job id to use. Cannot be provided together with segmentation_config.
12551286
segmentation_config: Configuration for video segmentation. Cannot be provided together with segmentation_id.
12561287
thumbnails_config: Optional configuration for segment thumbnails
@@ -1269,6 +1300,7 @@ def run(
12691300
enable_speech=enable_speech,
12701301
enable_scene_text=enable_scene_text,
12711302
enable_visual_scene_description=enable_visual_scene_description,
1303+
enable_audio_description=enable_audio_description,
12721304
segmentation_id=segmentation_id,
12731305
segmentation_config=segmentation_config,
12741306
thumbnails_config=thumbnails_config,
@@ -1311,6 +1343,7 @@ def create(
13111343
enable_speech: bool = True,
13121344
enable_scene_text: bool = True,
13131345
enable_visual_scene_description: bool = True,
1346+
enable_audio_description: bool = True,
13141347
segmentation_id: Optional[str] = None,
13151348
segmentation_config: Optional[Union[SegmentationConfig, Dict[str, Any]]] = None,
13161349
thumbnails_config: Optional[Union[Dict[str, Any], Any]] = None,
@@ -1323,6 +1356,7 @@ def create(
13231356
enable_speech: Whether to generate speech transcript.
13241357
enable_scene_text: Whether to generate scene text extraction.
13251358
enable_visual_scene_description: Whether to generate visual scene description.
1359+
enable_audio_description: Whether to generate audio description.
13261360
segmentation_id: Segmentation job id to use. Cannot be provided together with segmentation_config.
13271361
segmentation_config: Configuration for video segmentation. Cannot be provided together with segmentation_id.
13281362
thumbnails_config: Optional configuration for segment thumbnails
@@ -1355,6 +1389,7 @@ def create(
13551389
enable_speech=enable_speech,
13561390
enable_scene_text=enable_scene_text,
13571391
enable_visual_scene_description=enable_visual_scene_description,
1392+
enable_audio_description=enable_audio_description,
13581393
segmentation_id=segmentation_id,
13591394
segmentation_config=segmentation_config,
13601395
thumbnails_config=thumbnails_config_obj,
@@ -1368,13 +1403,20 @@ def create(
13681403
except Exception as e:
13691404
raise CloudGlueError(str(e))
13701405

1371-
def get(self, job_id: str, response_format: Optional[str] = None):
1406+
def get(
1407+
self,
1408+
job_id: str,
1409+
response_format: Optional[str] = None,
1410+
start_time_seconds: Optional[float] = None,
1411+
end_time_seconds: Optional[float] = None,
1412+
):
13721413
"""Get the status and data of a media description job.
13731414
13741415
Args:
13751416
job_id: The unique identifier of the description job.
13761417
response_format: The format of the response, one of 'json' or 'markdown' (json by default)
1377-
1418+
start_time_seconds: The start time in seconds to filter the media descriptions
1419+
end_time_seconds: The end time in seconds to filter the media descriptions
13781420
Returns:
13791421
The typed Describe job object with current status and data (if completed).
13801422
@@ -1383,7 +1425,7 @@ def get(self, job_id: str, response_format: Optional[str] = None):
13831425
"""
13841426
try:
13851427
# Use the standard method to get a properly typed object
1386-
response = self.api.get_describe(job_id=job_id, response_format=response_format)
1428+
response = self.api.get_describe(job_id=job_id, response_format=response_format, start_time_seconds=start_time_seconds, end_time_seconds=end_time_seconds)
13871429
return response
13881430
except ApiException as e:
13891431
raise CloudGlueError(str(e), e.status, e.data, e.headers, e.reason)
@@ -1443,6 +1485,7 @@ def run(
14431485
enable_speech: bool = True,
14441486
enable_scene_text: bool = True,
14451487
enable_visual_scene_description: bool = True,
1488+
enable_audio_description: bool = False,
14461489
segmentation_id: Optional[str] = None,
14471490
segmentation_config: Optional[Union[SegmentationConfig, Dict[str, Any]]] = None,
14481491
thumbnails_config: Optional[Union[Dict[str, Any], Any]] = None,
@@ -1458,6 +1501,7 @@ def run(
14581501
enable_speech: Whether to generate speech transcript.
14591502
enable_scene_text: Whether to generate scene text extraction.
14601503
enable_visual_scene_description: Whether to generate visual scene description.
1504+
enable_audio_description: Whether to generate audio description.
14611505
segmentation_id: Segmentation job id to use. Cannot be provided together with segmentation_config.
14621506
segmentation_config: Configuration for video segmentation. Cannot be provided together with segmentation_id.
14631507
thumbnails_config: Optional configuration for segment thumbnails
@@ -1476,6 +1520,7 @@ def run(
14761520
enable_speech=enable_speech,
14771521
enable_scene_text=enable_scene_text,
14781522
enable_visual_scene_description=enable_visual_scene_description,
1523+
enable_audio_description=enable_audio_description,
14791524
segmentation_id=segmentation_id,
14801525
segmentation_config=segmentation_config,
14811526
thumbnails_config=thumbnails_config,

cloudglue/sdk/README.md

Lines changed: 11 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)