Skip to content

Commit 0ea6431

Browse files
authored
Merge branch 'main' into ankit/add-transcode
2 parents fa73a1e + 48ee29d commit 0ea6431

File tree

5 files changed

+378
-0
lines changed

5 files changed

+378
-0
lines changed

videodb/__about__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
""" About information for videodb sdk"""
22

33

4+
45
__version__ = "0.2.15"
56
__title__ = "videodb"
67
__author__ = "videodb"

videodb/_constants.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@ class ApiPath:
7171
storage = "storage"
7272
download = "download"
7373
title = "title"
74+
rtstream = "rtstream"
75+
status = "status"
76+
event = "event"
77+
alert = "alert"
7478
generate_url = "generate_url"
7579
generate = "generate"
7680
web = "web"

videodb/client.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,30 @@ def get_invoices(self) -> List[dict]:
150150
"""
151151
return self.get(path=f"{ApiPath.billing}/{ApiPath.invoices}")
152152

153+
def create_event(self, event_prompt: str, label: str):
154+
"""Create an rtstream event.
155+
156+
:param str event_prompt: Prompt for the event
157+
:param str label: Label for the event
158+
:return: Event ID
159+
:rtype: str
160+
"""
161+
event_data = self.post(
162+
f"{ApiPath.rtstream}/{ApiPath.event}",
163+
data={"event_prompt": event_prompt, "label": label},
164+
)
165+
166+
return event_data.get("event_id")
167+
168+
def list_events(self):
169+
"""List all rtstream events.
170+
171+
:return: List of events
172+
:rtype: list[dict]
173+
"""
174+
event_data = self.get(f"{ApiPath.rtstream}/{ApiPath.event}")
175+
return event_data.get("events", [])
176+
153177
def download(self, stream_link: str, name: str) -> dict:
154178
"""Download a file from a stream link.
155179

videodb/collection.py

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from videodb.video import Video
1313
from videodb.audio import Audio
1414
from videodb.image import Image
15+
from videodb.rtstream import RTStream
1516
from videodb.search import SearchFactory, SearchResult
1617

1718
logger = logging.getLogger(__name__)
@@ -164,6 +165,53 @@ def delete_image(self, image_id: str) -> None:
164165
path=f"{ApiPath.image}/{image_id}", params={"collection_id": self.id}
165166
)
166167

168+
def connect_rtstream(
169+
self, url: str, name: str, sample_rate: int = None
170+
) -> RTStream:
171+
"""Connect to an rtstream.
172+
173+
:param str url: URL of the rtstream
174+
:param str name: Name of the rtstream
175+
:param int sample_rate: Sample rate of the rtstream (optional)
176+
:return: :class:`RTStream <RTStream>` object
177+
"""
178+
rtstream_data = self._connection.post(
179+
path=f"{ApiPath.rtstream}",
180+
data={
181+
"collection_id": self.id,
182+
"url": url,
183+
"name": name,
184+
"sample_rate": sample_rate,
185+
},
186+
)
187+
return RTStream(self._connection, **rtstream_data)
188+
189+
def get_rtstream(self, id: str) -> RTStream:
190+
"""Get an rtstream by its ID.
191+
192+
:param str id: ID of the rtstream
193+
:return: :class:`RTStream <RTStream>` object
194+
:rtype: :class:`videodb.rtstream.RTStream`
195+
"""
196+
rtstream_data = self._connection.get(
197+
path=f"{ApiPath.rtstream}/{id}",
198+
)
199+
return RTStream(self._connection, **rtstream_data)
200+
201+
def list_rtstreams(self) -> List[RTStream]:
202+
"""List all rtstreams in the collection.
203+
204+
:return: List of :class:`RTStream <RTStream>` objects
205+
:rtype: List[:class:`videodb.rtstream.RTStream`]
206+
"""
207+
rtstreams_data = self._connection.get(
208+
path=f"{ApiPath.rtstream}",
209+
)
210+
return [
211+
RTStream(self._connection, **rtstream)
212+
for rtstream in rtstreams_data.get("results")
213+
]
214+
167215
def generate_image(
168216
self,
169217
prompt: str,

0 commit comments

Comments
 (0)