From 30a88286bdda3f18a3dcddffc7b0f23097c62c19 Mon Sep 17 00:00:00 2001 From: Ankit raj <113342181+ankit-v2-3@users.noreply.github.com> Date: Fri, 19 Jul 2024 16:54:01 +0530 Subject: [PATCH 01/69] fix: keyword search --- videodb/search.py | 1 + 1 file changed, 1 insertion(+) diff --git a/videodb/search.py b/videodb/search.py index 168d10f..bef8fe2 100644 --- a/videodb/search.py +++ b/videodb/search.py @@ -184,6 +184,7 @@ def search_inside_video( "query": query, "score_threshold": score_threshold, "result_threshold": result_threshold, + **kwargs, }, ) return SearchResult(self._connection, **search_data) From 4ecb8ef8355a87021460de71170ce36a9421e206 Mon Sep 17 00:00:00 2001 From: Ankit raj <113342181+ankit-v2-3@users.noreply.github.com> Date: Fri, 19 Jul 2024 17:46:48 +0530 Subject: [PATCH 02/69] build: update version --- videodb/__about__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/videodb/__about__.py b/videodb/__about__.py index aa144bc..a264669 100644 --- a/videodb/__about__.py +++ b/videodb/__about__.py @@ -1,7 +1,7 @@ """ About information for videodb sdk""" -__version__ = "0.2.1" +__version__ = "0.2.2" __title__ = "videodb" __author__ = "videodb" __email__ = "contact@videodb.io" From c8ecceccc2503d34abd2177299fca6e48479e9da Mon Sep 17 00:00:00 2001 From: Ankit raj <113342181+ankit-v2-3@users.noreply.github.com> Date: Wed, 24 Jul 2024 18:44:39 +0530 Subject: [PATCH 03/69] docs: add docstrings --- videodb/audio.py | 6 ++ videodb/client.py | 57 +++++++++++++++++++ videodb/collection.py | 74 ++++++++++++++++++++++++- videodb/image.py | 13 +++++ videodb/scene.py | 13 +++++ videodb/search.py | 4 +- videodb/shot.py | 4 +- videodb/timeline.py | 19 +++++++ videodb/video.py | 124 ++++++++++++++++++++++++++++++++++++++++-- 9 files changed, 303 insertions(+), 11 deletions(-) diff --git a/videodb/audio.py b/videodb/audio.py index 7cab2b2..aabf03f 100644 --- a/videodb/audio.py +++ b/videodb/audio.py @@ -21,4 +21,10 @@ def __repr__(self) -> str: ) def delete(self) -> None: + """Delete the audio. + + :raises InvalidRequestError: If the delete fails + :return: None if the delete is successful + :rtype: None + """ self._connection.delete(f"{ApiPath.audio}/{self.id}") diff --git a/videodb/client.py b/videodb/client.py index a118f57..4df3c5e 100644 --- a/videodb/client.py +++ b/videodb/client.py @@ -24,13 +24,29 @@ class Connection(HttpClient): + """Connection class to interact with the VideoDB""" + def __init__(self, api_key: str, base_url: str) -> None: + """Initializes a new instance of the Connection class with specified API credentials. + + :param api_key: API key for authentication + :param str base_url: (optional) Base URL of the VideoDB API + :raise ValueError: If the API key is not provided + :return: connection object + :rtype: str + """ self.api_key = api_key self.base_url = base_url self.collection_id = "default" super().__init__(api_key=api_key, base_url=base_url, version=__version__) def get_collection(self, collection_id: Optional[str] = "default") -> Collection: + """Get a collection object by its ID. + + :param collection_id: ID of the collection + :return: :class:`Collection ` object + :rtype: :class:`videodb.collection.Collection` + """ collection_data = self.get(path=f"{ApiPath.collection}/{collection_id}") self.collection_id = collection_data.get("id", "default") return Collection( @@ -41,6 +57,11 @@ def get_collection(self, collection_id: Optional[str] = "default") -> Collection ) def get_collections(self) -> List[Collection]: + """Get a list of all collections. + + :return: List of :class:`Collection ` objects + :rtype: list[:class:`videodb.collection.Collection`] + """ collections_data = self.get(path=ApiPath.collection) return [ Collection( @@ -53,6 +74,13 @@ def get_collections(self) -> List[Collection]: ] def create_collection(self, name: str, description: str) -> Collection: + """Create a new collection. + + :param name: Name of the collection + :param description: Description of the collection + :return: :class:`Collection ` object + :rtype: :class:`videodb.collection.Collection` + """ collection_data = self.post( path=ApiPath.collection, data={ @@ -69,6 +97,14 @@ def create_collection(self, name: str, description: str) -> Collection: ) def update_collection(self, id: str, name: str, description: str) -> Collection: + """Update an existing collection. + + :param str id: ID of the collection + :param name: Name of the collection + :param description: Description of the collection + :return: :class:`Collection ` object + :rtype: :class:`videodb.collection.Collection` + """ collection_data = self.patch( path=f"{ApiPath.collection}/{id}", data={ @@ -85,9 +121,19 @@ def update_collection(self, id: str, name: str, description: str) -> Collection: ) def check_usage(self) -> dict: + """Check the usage. + + :return: Usage data + :rtype: dict + """ return self.get(path=f"{ApiPath.billing}/{ApiPath.usage}") def get_invoices(self) -> List[dict]: + """Get a list of all invoices. + + :return: List of invoices + :rtype: list of dict + """ return self.get(path=f"{ApiPath.billing}/{ApiPath.invoices}") def upload( @@ -99,6 +145,17 @@ def upload( description: Optional[str] = None, callback_url: Optional[str] = None, ) -> Union[Video, Audio, Image, None]: + """Upload a file. + + :param file_path: Path to the file to upload + :param url: URL of the file to upload + :param MediaType media_type:(optional):class:`MediaType ` object + :param name:(optional) Name of the file + :param description:(optional) Description of the file + :param callback_url:(optional) URL to receive the callback + :return: :class:`Video