From 2ab473e6d3e75df6bebc76ae00e08dc8f89da083 Mon Sep 17 00:00:00 2001 From: Ankit raj <113342181+ankit-v2-3@users.noreply.github.com> Date: Fri, 9 Feb 2024 09:16:56 +0530 Subject: [PATCH 1/8] feat: add image and ImageAsset --- videodb/_constants.py | 2 ++ videodb/asset.py | 32 ++++++++++++++++++++++++++++++++ videodb/client.py | 5 ++++- videodb/collection.py | 16 +++++++++++++++- videodb/image.py | 22 ++++++++++++++++++++++ videodb/timeline.py | 8 ++++---- 6 files changed, 79 insertions(+), 6 deletions(-) create mode 100644 videodb/image.py diff --git a/videodb/_constants.py b/videodb/_constants.py index 7d4b864..438a2e4 100644 --- a/videodb/_constants.py +++ b/videodb/_constants.py @@ -7,6 +7,7 @@ class MediaType: video = "video" audio = "audio" + image = "image" class SearchType: @@ -31,6 +32,7 @@ class ApiPath: upload = "upload" video = "video" audio = "audio" + image = "image" stream = "stream" thumbnail = "thumbnail" upload_url = "upload_url" diff --git a/videodb/asset.py b/videodb/asset.py index 97c3d31..72fea4e 100644 --- a/videodb/asset.py +++ b/videodb/asset.py @@ -85,3 +85,35 @@ def __repr__(self) -> str: f"fade_in_duration={self.fade_in_duration}, " f"fade_out_duration={self.fade_out_duration})" ) + + +class ImageAsset(MediaAsset): + def __init__( + self, + asset_id: str, + width: Optional[int] = 100, + height: Optional[int] = 100, + position_x: Optional[int] = 80, + position_y: Optional[int] = 20, + end: Optional[Union[int, None]] = None, + ) -> None: + super().__init__(asset_id) + self.width = width + self.height = height + self.position_x = position_x + self.position_y = position_y + self.end = end + + def to_json(self) -> dict: + return copy.deepcopy(self.__dict__) + + def __repr__(self) -> str: + return ( + f"ImageAsset(" + f"asset_id={self.asset_id}, " + f"width={self.width}, " + f"height={self.height}, " + f"position_x={self.position_x}, " + f"position_y={self.position_y}, " + f"end={self.end})" + ) diff --git a/videodb/client.py b/videodb/client.py index 001e586..4acf9c6 100644 --- a/videodb/client.py +++ b/videodb/client.py @@ -13,6 +13,7 @@ from videodb._utils._http_client import HttpClient from videodb.video import Video from videodb.audio import Audio +from videodb.image import Image from videodb._upload import ( upload, @@ -46,7 +47,7 @@ def upload( name: Optional[str] = None, description: Optional[str] = None, callback_url: Optional[str] = None, - ) -> Union[Video, Audio, None]: + ) -> Union[Video, Audio, Image, None]: upload_data = upload( self, file_path, @@ -60,3 +61,5 @@ def upload( return Video(self, **upload_data) if upload_data else None elif upload_data.get("id").startswith("a-"): return Audio(self, **upload_data) if upload_data else None + elif upload_data.get("id").startswith("i-"): + return Image(self, **upload_data) if upload_data else None diff --git a/videodb/collection.py b/videodb/collection.py index c508056..dbbc2c6 100644 --- a/videodb/collection.py +++ b/videodb/collection.py @@ -13,6 +13,7 @@ ) from videodb.video import Video from videodb.audio import Audio +from videodb.image import Image from videodb.search import SearchFactory, SearchResult logger = logging.getLogger(__name__) @@ -54,6 +55,17 @@ def get_audio(self, audio_id: str) -> Audio: def delete_audio(self, audio_id: str) -> None: return self._connection.delete(path=f"{ApiPath.audio}/{audio_id}") + def get_images(self) -> list[Image]: + images_data = self._connection.get(path=f"{ApiPath.image}") + return [Image(self._connection, **image) for image in images_data.get("images")] + + def get_image(self, image_id: str) -> Image: + image_data = self._connection.get(path=f"{ApiPath.image}/{image_id}") + return Image(self._connection, **image_data) + + def delete_image(self, image_id: str) -> None: + return self._connection.delete(path=f"{ApiPath.image}/{image_id}") + def search( self, query: str, @@ -79,7 +91,7 @@ def upload( name: Optional[str] = None, description: Optional[str] = None, callback_url: Optional[str] = None, - ) -> Union[Video, Audio, None]: + ) -> Union[Video, Audio, Image, None]: upload_data = upload( self._connection, file_path, @@ -93,3 +105,5 @@ def upload( return Video(self._connection, **upload_data) if upload_data else None elif upload_data.get("id").startswith("a-"): return Audio(self._connection, **upload_data) if upload_data else None + elif upload_data.get("id").startswith("i-"): + return Image(self._connection, **upload_data) if upload_data else None diff --git a/videodb/image.py b/videodb/image.py new file mode 100644 index 0000000..69e0ec3 --- /dev/null +++ b/videodb/image.py @@ -0,0 +1,22 @@ +from videodb._constants import ( + ApiPath, +) + + +class Image: + def __init__(self, _connection, id: str, collection_id: str, **kwargs) -> None: + self._connection = _connection + self.id = id + self.collection_id = collection_id + self.name = kwargs.get("name", None) + + def __repr__(self) -> str: + return ( + f"Image(" + f"id={self.id}, " + f"collection_id={self.collection_id}, " + f"name={self.name})" + ) + + def delete(self) -> None: + self._connection.delete(f"{ApiPath.image}/{self.id}") diff --git a/videodb/timeline.py b/videodb/timeline.py index c0720cd..96b66bf 100644 --- a/videodb/timeline.py +++ b/videodb/timeline.py @@ -1,7 +1,7 @@ from typing import Union from videodb._constants import ApiPath -from videodb.asset import VideoAsset, AudioAsset +from videodb.asset import VideoAsset, AudioAsset, ImageAsset class Timeline(object): @@ -28,9 +28,9 @@ def add_inline(self, asset: Union[VideoAsset]) -> None: raise ValueError("asset must be of type VideoAsset") self._timeline.append(asset) - def add_overlay(self, start: int, asset: Union[AudioAsset]) -> None: - if not isinstance(asset, AudioAsset): - raise ValueError("asset must be of type AudioAsset") + def add_overlay(self, start: int, asset: Union[AudioAsset, ImageAsset]) -> None: + if not isinstance(asset, AudioAsset) and not isinstance(asset, ImageAsset): + raise ValueError("asset must be of type AudioAsset or ImageAsset") self._timeline.append((start, asset)) def generate_stream(self) -> str: From 15bd1843077f095794a6c3c465fad3f35f4e1bab Mon Sep 17 00:00:00 2001 From: Ankit raj <113342181+ankit-v2-3@users.noreply.github.com> Date: Wed, 14 Feb 2024 20:30:21 +0530 Subject: [PATCH 2/8] feat: add subtitle style --- videodb/__init__.py | 2 +- videodb/_constants.py | 42 +++++++++++++++++++++++++++++++++++++ videodb/video.py | 49 ++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 91 insertions(+), 2 deletions(-) diff --git a/videodb/__init__.py b/videodb/__init__.py index 62accc2..2f06d5f 100644 --- a/videodb/__init__.py +++ b/videodb/__init__.py @@ -16,7 +16,7 @@ logger: logging.Logger = logging.getLogger("videodb") -__version__ = "0.0.3" +__version__ = "0.0.4" __author__ = "videodb" __all__ = [ diff --git a/videodb/_constants.py b/videodb/_constants.py index 438a2e4..076dbc2 100644 --- a/videodb/_constants.py +++ b/videodb/_constants.py @@ -58,3 +58,45 @@ class HttpClientDefaultValues: class MaxSupported: fade_duration = 5 + + +class SubtitleBorderStyle: + no_border = 1 + opaque_box = 3 + outline = 4 + + +class SubtitleAlignment: + bottom_left = 1 + bottom_center = 2 + bottom_right = 3 + middle_left = 4 + middle_center = 5 + middle_right = 6 + top_left = 7 + top_center = 8 + top_right = 9 + + +class SubtitleStyleDefaultValues: + font_name: str = "Arial" + font_size: float = 18 + primary_colour: str = "&H00FFFFFF" # white + secondary_colour: str = "&H000000FF" # blue + outline_colour: str = "&H00000000" # black + back_colour: str = "&H00000000" # black + bold: bool = False + italic: bool = False + underline: bool = False + strike_out: bool = False + scale_x: float = 1.0 + scale_y: float = 1.0 + spacing: float = 0 + angle: float = 0 + border_style: int = SubtitleBorderStyle.outline + outline: float = 1.0 + shadow: float = 0.0 + alignment: int = SubtitleAlignment.bottom_center + margin_l: int = 10 + margin_r: int = 10 + margin_v: int = 10 diff --git a/videodb/video.py b/videodb/video.py index 0d48280..e4a4592 100644 --- a/videodb/video.py +++ b/videodb/video.py @@ -5,6 +5,7 @@ SearchType, IndexType, Workflows, + SubtitleStyleDefaultValues, ) from videodb.search import SearchFactory, SearchResult from videodb.shot import Shot @@ -129,11 +130,57 @@ def index_spoken_words(self) -> None: }, ) - def add_subtitle(self) -> str: + def add_subtitle( + self, + font_name: str = SubtitleStyleDefaultValues.font_name, + font_size: float = SubtitleStyleDefaultValues.font_size, + primary_colour: str = SubtitleStyleDefaultValues.primary_colour, + secondary_colour: str = SubtitleStyleDefaultValues.secondary_colour, + outline_colour: str = SubtitleStyleDefaultValues.outline_colour, + back_colour: str = SubtitleStyleDefaultValues.back_colour, + bold: bool = SubtitleStyleDefaultValues.bold, + italic: bool = SubtitleStyleDefaultValues.italic, + underline: bool = SubtitleStyleDefaultValues.underline, + strike_out: bool = SubtitleStyleDefaultValues.strike_out, + scale_x: float = SubtitleStyleDefaultValues.scale_x, + scale_y: float = SubtitleStyleDefaultValues.scale_x, + spacing: float = SubtitleStyleDefaultValues.spacing, + angle: float = SubtitleStyleDefaultValues.angle, + border_style: int = SubtitleStyleDefaultValues.border_style, + outline: float = SubtitleStyleDefaultValues.outline, + shadow: float = SubtitleStyleDefaultValues.shadow, + alignment: int = SubtitleStyleDefaultValues.alignment, + margin_l: int = SubtitleStyleDefaultValues.margin_l, + margin_r: int = SubtitleStyleDefaultValues.margin_r, + margin_v: int = SubtitleStyleDefaultValues.margin_v, + ) -> str: subtitle_data = self._connection.post( path=f"{ApiPath.video}/{self.id}/{ApiPath.workflow}", data={ "type": Workflows.add_subtitles, + "subtitle_style": { + "font_name": font_name, + "font_size": font_size, + "primary_colour": primary_colour, + "secondary_colour": secondary_colour, + "outline_colour": outline_colour, + "back_colour": back_colour, + "bold": bold, + "italic": italic, + "underline": underline, + "strike_out": strike_out, + "scale_x": scale_x, + "scale_y": scale_y, + "spacing": spacing, + "angle": angle, + "border_style": border_style, + "outline": outline, + "shadow": shadow, + "alignment": alignment, + "margin_l": margin_l, + "margin_r": margin_r, + "margin_v": margin_v, + }, }, ) return subtitle_data.get("stream_url", None) From aae1b06fd3e4b2e3926f0a5d9fd314702910015b Mon Sep 17 00:00:00 2001 From: Ankit raj <113342181+ankit-v2-3@users.noreply.github.com> Date: Mon, 19 Feb 2024 12:18:50 +0530 Subject: [PATCH 3/8] fix: media_id TypeError --- videodb/client.py | 6 +++--- videodb/collection.py | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/videodb/client.py b/videodb/client.py index 4acf9c6..4bbaba4 100644 --- a/videodb/client.py +++ b/videodb/client.py @@ -57,9 +57,9 @@ def upload( description, callback_url, ) - if upload_data.get("id").startswith("m-"): + if upload_data.get("id", "").startswith("m-"): return Video(self, **upload_data) if upload_data else None - elif upload_data.get("id").startswith("a-"): + elif upload_data.get("id", "").startswith("a-"): return Audio(self, **upload_data) if upload_data else None - elif upload_data.get("id").startswith("i-"): + elif upload_data.get("id", "").startswith("i-"): return Image(self, **upload_data) if upload_data else None diff --git a/videodb/collection.py b/videodb/collection.py index dbbc2c6..a0d977a 100644 --- a/videodb/collection.py +++ b/videodb/collection.py @@ -101,9 +101,9 @@ def upload( description, callback_url, ) - if upload_data.get("id").startswith("m-"): + if upload_data.get("id", "").startswith("m-"): return Video(self._connection, **upload_data) if upload_data else None - elif upload_data.get("id").startswith("a-"): + elif upload_data.get("id", "").startswith("a-"): return Audio(self._connection, **upload_data) if upload_data else None - elif upload_data.get("id").startswith("i-"): + elif upload_data.get("id", "").startswith("i-"): return Image(self._connection, **upload_data) if upload_data else None From 62ac7355180c6980f5dd112c0556a39312ffb4f2 Mon Sep 17 00:00:00 2001 From: Ankit raj <113342181+ankit-v2-3@users.noreply.github.com> Date: Wed, 21 Feb 2024 18:04:52 +0530 Subject: [PATCH 4/8] feat: add keyward search --- videodb/__init__.py | 3 ++- videodb/_constants.py | 1 + videodb/search.py | 30 +++++++++++++++++++++++++++++- 3 files changed, 32 insertions(+), 2 deletions(-) diff --git a/videodb/__init__.py b/videodb/__init__.py index 62accc2..67a04e4 100644 --- a/videodb/__init__.py +++ b/videodb/__init__.py @@ -5,7 +5,7 @@ from typing import Optional from videodb._utils._video import play_stream -from videodb._constants import VIDEO_DB_API, MediaType +from videodb._constants import VIDEO_DB_API, MediaType, SearchType from videodb.client import Connection from videodb.exceptions import ( VideodbError, @@ -26,6 +26,7 @@ "SearchError", "play_stream", "MediaType", + "SearchType", ] diff --git a/videodb/_constants.py b/videodb/_constants.py index 7d4b864..ea085d9 100644 --- a/videodb/_constants.py +++ b/videodb/_constants.py @@ -11,6 +11,7 @@ class MediaType: class SearchType: semantic = "semantic" + keyword = "keyword" class IndexType: diff --git a/videodb/search.py b/videodb/search.py index f42f645..c42eea3 100644 --- a/videodb/search.py +++ b/videodb/search.py @@ -148,7 +148,35 @@ def search_inside_collection( return SearchResult(self._connection, **search_data) -search_type = {SearchType.semantic: SemanticSearch} +class KeywordSearch(Search): + def __init__(self, _connection): + self._connection = _connection + + def search_inside_video( + self, + video_id: str, + query: str, + result_threshold: Optional[int] = None, + score_threshold: Optional[int] = None, + dynamic_score_percentage: Optional[int] = None, + **kwargs, + ): + search_data = self._connection.post( + path=f"{ApiPath.video}/{video_id}/{ApiPath.search}", + data={ + "type": SearchType.keyword, + "query": query, + "score_threshold": score_threshold, + "result_threshold": result_threshold, + }, + ) + return SearchResult(self._connection, **search_data) + + def search_inside_collection(**kwargs): + raise NotImplementedError("Keyword search will be implemented in the future") + + +search_type = {SearchType.semantic: SemanticSearch, SearchType.keyword: KeywordSearch} class SearchFactory: From 17a195f8e95b41e38ee7e8ec5ba234d8b6c51825 Mon Sep 17 00:00:00 2001 From: Ankit raj <113342181+ankit-v2-3@users.noreply.github.com> Date: Wed, 21 Feb 2024 18:59:14 +0530 Subject: [PATCH 5/8] fix: index type --- videodb/__init__.py | 2 +- videodb/search.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/videodb/__init__.py b/videodb/__init__.py index 67a04e4..9fe49ab 100644 --- a/videodb/__init__.py +++ b/videodb/__init__.py @@ -16,7 +16,7 @@ logger: logging.Logger = logging.getLogger("videodb") -__version__ = "0.0.3" +__version__ = "0.0.4" __author__ = "videodb" __all__ = [ diff --git a/videodb/search.py b/videodb/search.py index c42eea3..49db816 100644 --- a/videodb/search.py +++ b/videodb/search.py @@ -116,7 +116,7 @@ def search_inside_video( search_data = self._connection.post( path=f"{ApiPath.video}/{video_id}/{ApiPath.search}", data={ - "type": SearchType.semantic, + "index_type": SearchType.semantic, "query": query, "score_threshold": score_threshold or SemanticSearchDefaultValues.score_threshold, @@ -137,7 +137,7 @@ def search_inside_collection( search_data = self._connection.post( path=f"{ApiPath.collection}/{collection_id}/{ApiPath.search}", data={ - "type": SearchType.semantic, + "index_type": SearchType.semantic, "query": query, "score_threshold": score_threshold or SemanticSearchDefaultValues.score_threshold, @@ -164,7 +164,7 @@ def search_inside_video( search_data = self._connection.post( path=f"{ApiPath.video}/{video_id}/{ApiPath.search}", data={ - "type": SearchType.keyword, + "index_type": SearchType.keyword, "query": query, "score_threshold": score_threshold, "result_threshold": result_threshold, From 5d6cc0d2619a5c73d551a5fce2e90a37861be0b8 Mon Sep 17 00:00:00 2001 From: Ankit raj <113342181+ankit-v2-3@users.noreply.github.com> Date: Thu, 22 Feb 2024 12:35:00 +0530 Subject: [PATCH 6/8] feat: add SubtitleStyle --- videodb/__init__.py | 11 ++++++++- videodb/_constants.py | 4 +++- videodb/asset.py | 18 +++++++-------- videodb/client.py | 13 ++++++----- videodb/collection.py | 13 ++++++----- videodb/video.py | 53 ++++--------------------------------------- 6 files changed, 41 insertions(+), 71 deletions(-) diff --git a/videodb/__init__.py b/videodb/__init__.py index 2f06d5f..4fb34ba 100644 --- a/videodb/__init__.py +++ b/videodb/__init__.py @@ -5,7 +5,13 @@ from typing import Optional from videodb._utils._video import play_stream -from videodb._constants import VIDEO_DB_API, MediaType +from videodb._constants import ( + VIDEO_DB_API, + MediaType, + SubtitleAlignment, + SubtitleBorderStyle, + SubtitleStyle, +) from videodb.client import Connection from videodb.exceptions import ( VideodbError, @@ -26,6 +32,9 @@ "SearchError", "play_stream", "MediaType", + "SubtitleAlignment", + "SubtitleBorderStyle", + "SubtitleStyle", ] diff --git a/videodb/_constants.py b/videodb/_constants.py index 076dbc2..9f4c23a 100644 --- a/videodb/_constants.py +++ b/videodb/_constants.py @@ -1,5 +1,6 @@ """Constants used in the videodb package.""" +from dataclasses import dataclass VIDEO_DB_API: str = "https://api.videodb.io" @@ -78,7 +79,8 @@ class SubtitleAlignment: top_right = 9 -class SubtitleStyleDefaultValues: +@dataclass +class SubtitleStyle: font_name: str = "Arial" font_size: float = 18 primary_colour: str = "&H00FFFFFF" # white diff --git a/videodb/asset.py b/videodb/asset.py index 72fea4e..1feb700 100644 --- a/videodb/asset.py +++ b/videodb/asset.py @@ -93,16 +93,16 @@ def __init__( asset_id: str, width: Optional[int] = 100, height: Optional[int] = 100, - position_x: Optional[int] = 80, - position_y: Optional[int] = 20, - end: Optional[Union[int, None]] = None, + x: Optional[int] = 80, + y: Optional[int] = 20, + duration: Optional[Union[int, None]] = None, ) -> None: super().__init__(asset_id) self.width = width self.height = height - self.position_x = position_x - self.position_y = position_y - self.end = end + self.x = x + self.y = y + self.duration = duration def to_json(self) -> dict: return copy.deepcopy(self.__dict__) @@ -113,7 +113,7 @@ def __repr__(self) -> str: f"asset_id={self.asset_id}, " f"width={self.width}, " f"height={self.height}, " - f"position_x={self.position_x}, " - f"position_y={self.position_y}, " - f"end={self.end})" + f"x={self.x}, " + f"y={self.y}, " + f"duration={self.duration})" ) diff --git a/videodb/client.py b/videodb/client.py index 4bbaba4..fd823f9 100644 --- a/videodb/client.py +++ b/videodb/client.py @@ -57,9 +57,10 @@ def upload( description, callback_url, ) - if upload_data.get("id", "").startswith("m-"): - return Video(self, **upload_data) if upload_data else None - elif upload_data.get("id", "").startswith("a-"): - return Audio(self, **upload_data) if upload_data else None - elif upload_data.get("id", "").startswith("i-"): - return Image(self, **upload_data) if upload_data else None + media_id = upload_data.get("id", "") + if media_id.startswith("m-"): + return Video(self, **upload_data) + elif media_id.startswith("a-"): + return Audio(self, **upload_data) + elif media_id.startswith("img-"): + return Image(self, **upload_data) diff --git a/videodb/collection.py b/videodb/collection.py index a0d977a..b9a69fb 100644 --- a/videodb/collection.py +++ b/videodb/collection.py @@ -101,9 +101,10 @@ def upload( description, callback_url, ) - if upload_data.get("id", "").startswith("m-"): - return Video(self._connection, **upload_data) if upload_data else None - elif upload_data.get("id", "").startswith("a-"): - return Audio(self._connection, **upload_data) if upload_data else None - elif upload_data.get("id", "").startswith("i-"): - return Image(self._connection, **upload_data) if upload_data else None + media_id = upload_data.get("id", "") + if media_id.startswith("m-"): + return Video(self, **upload_data) + elif media_id.startswith("a-"): + return Audio(self, **upload_data) + elif media_id.startswith("img-"): + return Image(self, **upload_data) diff --git a/videodb/video.py b/videodb/video.py index e4a4592..6e8f3dc 100644 --- a/videodb/video.py +++ b/videodb/video.py @@ -5,7 +5,7 @@ SearchType, IndexType, Workflows, - SubtitleStyleDefaultValues, + SubtitleStyle, ) from videodb.search import SearchFactory, SearchResult from videodb.shot import Shot @@ -130,57 +130,14 @@ def index_spoken_words(self) -> None: }, ) - def add_subtitle( - self, - font_name: str = SubtitleStyleDefaultValues.font_name, - font_size: float = SubtitleStyleDefaultValues.font_size, - primary_colour: str = SubtitleStyleDefaultValues.primary_colour, - secondary_colour: str = SubtitleStyleDefaultValues.secondary_colour, - outline_colour: str = SubtitleStyleDefaultValues.outline_colour, - back_colour: str = SubtitleStyleDefaultValues.back_colour, - bold: bool = SubtitleStyleDefaultValues.bold, - italic: bool = SubtitleStyleDefaultValues.italic, - underline: bool = SubtitleStyleDefaultValues.underline, - strike_out: bool = SubtitleStyleDefaultValues.strike_out, - scale_x: float = SubtitleStyleDefaultValues.scale_x, - scale_y: float = SubtitleStyleDefaultValues.scale_x, - spacing: float = SubtitleStyleDefaultValues.spacing, - angle: float = SubtitleStyleDefaultValues.angle, - border_style: int = SubtitleStyleDefaultValues.border_style, - outline: float = SubtitleStyleDefaultValues.outline, - shadow: float = SubtitleStyleDefaultValues.shadow, - alignment: int = SubtitleStyleDefaultValues.alignment, - margin_l: int = SubtitleStyleDefaultValues.margin_l, - margin_r: int = SubtitleStyleDefaultValues.margin_r, - margin_v: int = SubtitleStyleDefaultValues.margin_v, - ) -> str: + def add_subtitle(self, style: SubtitleStyle = SubtitleStyle()) -> str: + if not isinstance(style, SubtitleStyle): + raise ValueError("style must be of type SubtitleStyle") subtitle_data = self._connection.post( path=f"{ApiPath.video}/{self.id}/{ApiPath.workflow}", data={ "type": Workflows.add_subtitles, - "subtitle_style": { - "font_name": font_name, - "font_size": font_size, - "primary_colour": primary_colour, - "secondary_colour": secondary_colour, - "outline_colour": outline_colour, - "back_colour": back_colour, - "bold": bold, - "italic": italic, - "underline": underline, - "strike_out": strike_out, - "scale_x": scale_x, - "scale_y": scale_y, - "spacing": spacing, - "angle": angle, - "border_style": border_style, - "outline": outline, - "shadow": shadow, - "alignment": alignment, - "margin_l": margin_l, - "margin_r": margin_r, - "margin_v": margin_v, - }, + "subtitle_style": style.__dict__, }, ) return subtitle_data.get("stream_url", None) From 30da85a81130128c2611f211ae6bdc9b63ea0fd8 Mon Sep 17 00:00:00 2001 From: Ankit raj <113342181+ankit-v2-3@users.noreply.github.com> Date: Thu, 22 Feb 2024 15:13:49 +0530 Subject: [PATCH 7/8] docs: add type hint --- videodb/asset.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/videodb/asset.py b/videodb/asset.py index 1feb700..e64a103 100644 --- a/videodb/asset.py +++ b/videodb/asset.py @@ -91,11 +91,11 @@ class ImageAsset(MediaAsset): def __init__( self, asset_id: str, - width: Optional[int] = 100, - height: Optional[int] = 100, - x: Optional[int] = 80, - y: Optional[int] = 20, - duration: Optional[Union[int, None]] = None, + width: Union[int, str] = 100, + height: Union[int, str] = 100, + x: Union[int, str] = 80, + y: Union[int, str] = 20, + duration: Optional[int] = None, ) -> None: super().__init__(asset_id) self.width = width From 2eaa0b3cfb22a488d79fdda350a4fff4fa9ad2a4 Mon Sep 17 00:00:00 2001 From: Ankit raj <113342181+ankit-v2-3@users.noreply.github.com> Date: Thu, 22 Feb 2024 15:47:35 +0530 Subject: [PATCH 8/8] fix: connection --- videodb/collection.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/videodb/collection.py b/videodb/collection.py index b9a69fb..489a56b 100644 --- a/videodb/collection.py +++ b/videodb/collection.py @@ -103,8 +103,8 @@ def upload( ) media_id = upload_data.get("id", "") if media_id.startswith("m-"): - return Video(self, **upload_data) + return Video(self._connection, **upload_data) elif media_id.startswith("a-"): - return Audio(self, **upload_data) + return Audio(self._connection, **upload_data) elif media_id.startswith("img-"): - return Image(self, **upload_data) + return Image(self._connection, **upload_data)