diff --git a/videodb/__about__.py b/videodb/__about__.py index d152662..7e93884 100644 --- a/videodb/__about__.py +++ b/videodb/__about__.py @@ -1,7 +1,7 @@ """ About information for videodb sdk""" -__version__ = "0.2.11" +__version__ = "0.2.12" __title__ = "videodb" __author__ = "videodb" __email__ = "contact@videodb.io" diff --git a/videodb/_constants.py b/videodb/_constants.py index 173c825..b155752 100644 --- a/videodb/_constants.py +++ b/videodb/_constants.py @@ -72,6 +72,10 @@ class ApiPath: download = "download" title = "title" generate_url = "generate_url" + generate = "generate" + web = "web" + translate = "translate" + dub = "dub" class Status: diff --git a/videodb/client.py b/videodb/client.py index f47df97..7cbfbfd 100644 --- a/videodb/client.py +++ b/videodb/client.py @@ -110,7 +110,7 @@ def update_collection(self, id: str, name: str, description: str) -> Collection: """Update an existing collection. :param str id: ID of the collection - :param str name: Name of the collection + :param str name: Name of the collection :param str description: Description of the collection :return: :class:`Collection ` object :rtype: :class:`videodb.collection.Collection` @@ -163,6 +163,31 @@ def download(self, stream_link: str, name: str) -> dict: }, ) + def youtube_search( + self, + query: str, + result_threshold: Optional[int] = 10, + duration: str = "medium", + ) -> List[dict]: + """Search for a query on YouTube. + + :param str query: Query to search for + :param int result_threshold: Number of results to return (optional) + :param str duration: Duration of the video (optional) + :return: List of YouTube search results + :rtype: List[dict] + """ + search_data = self.post( + path=f"{ApiPath.collection}/{self.collection_id}/{ApiPath.search}/{ApiPath.web}", + data={ + "query": query, + "result_threshold": result_threshold, + "platform": "youtube", + "duration": duration, + }, + ) + return search_data.get("results") + def upload( self, file_path: str = None, diff --git a/videodb/collection.py b/videodb/collection.py index 756ab5d..25a86ec 100644 --- a/videodb/collection.py +++ b/videodb/collection.py @@ -1,12 +1,6 @@ import logging -from typing import ( - Optional, - Union, - List, - Dict, - Any, -) +from typing import Optional, Union, List, Dict, Any, Literal from videodb._upload import ( upload, ) @@ -170,6 +164,134 @@ def delete_image(self, image_id: str) -> None: path=f"{ApiPath.image}/{image_id}", params={"collection_id": self.id} ) + def generate_image( + self, + prompt: str, + aspect_ratio: Optional[Literal["1:1", "9:16", "16:9", "4:3", "3:4"]] = "1:1", + callback_url: Optional[str] = None, + ) -> Image: + """Generate an image from a prompt. + + :param str prompt: Prompt for the image generation + :param str aspect_ratio: Aspect ratio of the image (optional) + :param str callback_url: URL to receive the callback (optional) + :return: :class:`Image ` object + :rtype: :class:`videodb.image.Image` + """ + image_data = self._connection.post( + path=f"{ApiPath.collection}/{self.id}/{ApiPath.generate}/{ApiPath.image}", + data={ + "prompt": prompt, + "aspect_ratio": aspect_ratio, + "callback_url": callback_url, + }, + ) + if image_data: + return Image(self._connection, **image_data) + + def generate_music( + self, prompt: str, duration: int = 5, callback_url: Optional[str] = None + ) -> Audio: + """Generate music from a prompt. + + :param str prompt: Prompt for the music generation + :param int duration: Duration of the music in seconds + :param str callback_url: URL to receive the callback (optional) + :return: :class:`Audio