From b6dfee058c18686bd12b7334532828098dacd806 Mon Sep 17 00:00:00 2001 From: Ankit raj <113342181+ankit-v2-3@users.noreply.github.com> Date: Wed, 5 Feb 2025 13:56:48 +0530 Subject: [PATCH] feat: add generate url --- videodb/__about__.py | 2 +- videodb/_constants.py | 1 + videodb/audio.py | 7 +++++++ videodb/client.py | 5 ++++- videodb/image.py | 7 +++++++ 5 files changed, 20 insertions(+), 2 deletions(-) diff --git a/videodb/__about__.py b/videodb/__about__.py index e4175e3..6a88c81 100644 --- a/videodb/__about__.py +++ b/videodb/__about__.py @@ -1,7 +1,7 @@ """ About information for videodb sdk""" -__version__ = "0.2.9" +__version__ = "0.2.10" __title__ = "videodb" __author__ = "videodb" __email__ = "contact@videodb.io" diff --git a/videodb/_constants.py b/videodb/_constants.py index b5eab1c..9acfa22 100644 --- a/videodb/_constants.py +++ b/videodb/_constants.py @@ -70,6 +70,7 @@ class ApiPath: storage = "storage" download = "download" title = "title" + generate_url = "generate_url" class Status: diff --git a/videodb/audio.py b/videodb/audio.py index 7cab2b2..1e2df60 100644 --- a/videodb/audio.py +++ b/videodb/audio.py @@ -20,5 +20,12 @@ def __repr__(self) -> str: f"length={self.length})" ) + def generate_url(self) -> str: + url_data = self._connection.post( + path=f"{ApiPath.audio}/{self.id}/{ApiPath.generate_url}", + params={"collection_id": self.collection_id}, + ) + return url_data.get("signed_url", None) + def delete(self) -> None: self._connection.delete(f"{ApiPath.audio}/{self.id}") diff --git a/videodb/client.py b/videodb/client.py index 9a29b73..3fbee06 100644 --- a/videodb/client.py +++ b/videodb/client.py @@ -54,12 +54,15 @@ def get_collections(self) -> List[Collection]: for collection in collections_data.get("collections") ] - def create_collection(self, name: str, description: str) -> Collection: + def create_collection( + self, name: str, description: str, is_public: bool = False + ) -> Collection: collection_data = self.post( path=ApiPath.collection, data={ "name": name, "description": description, + "is_public": is_public, }, ) self.collection_id = collection_data.get("id", "default") diff --git a/videodb/image.py b/videodb/image.py index 5a97b87..5aa1acf 100644 --- a/videodb/image.py +++ b/videodb/image.py @@ -20,6 +20,13 @@ def __repr__(self) -> str: f"url={self.url})" ) + def generate_url(self) -> str: + url_data = self._connection.post( + path=f"{ApiPath.image}/{self.id}/{ApiPath.generate_url}", + params={"collection_id": self.collection_id}, + ) + return url_data.get("signed_url", None) + def delete(self) -> None: self._connection.delete(f"{ApiPath.image}/{self.id}")