Skip to content

Commit 401101d

Browse files
committed
fix merge conflict and merge main
2 parents e2b7523 + fbc857b commit 401101d

File tree

8 files changed

+157
-16
lines changed

8 files changed

+157
-16
lines changed

videodb/__about__.py

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

33

4-
__version__ = "0.2.2"
4+
__version__ = "0.2.10"
55
__title__ = "videodb"
66
__author__ = "videodb"
77
__email__ = "[email protected]"

videodb/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
SceneExtractionType,
1212
MediaType,
1313
SearchType,
14+
Segmenter,
1415
SubtitleAlignment,
1516
SubtitleBorderStyle,
1617
SubtitleStyle,
@@ -41,6 +42,7 @@
4142
"SubtitleStyle",
4243
"TextStyle",
4344
"SceneExtractionType",
45+
"Segmenter",
4446
]
4547

4648

videodb/_constants.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ class SearchType:
1515
semantic = "semantic"
1616
keyword = "keyword"
1717
scene = "scene"
18+
llm = "llm"
1819

1920

2021
class IndexType:
@@ -36,6 +37,12 @@ class SemanticSearchDefaultValues:
3637
score_threshold = 0.2
3738

3839

40+
class Segmenter:
41+
time = "time"
42+
word = "word"
43+
sentence = "sentence"
44+
45+
3946
class ApiPath:
4047
collection = "collection"
4148
upload = "upload"
@@ -60,6 +67,10 @@ class ApiPath:
6067
scene = "scene"
6168
frame = "frame"
6269
describe = "describe"
70+
storage = "storage"
71+
download = "download"
72+
title = "title"
73+
generate_url = "generate_url"
6374

6475

6576
class Status:

videodb/audio.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,13 @@ def __repr__(self) -> str:
2020
f"length={self.length})"
2121
)
2222

23+
def generate_url(self) -> str:
24+
url_data = self._connection.post(
25+
path=f"{ApiPath.audio}/{self.id}/{ApiPath.generate_url}",
26+
params={"collection_id": self.collection_id},
27+
)
28+
return url_data.get("signed_url", None)
29+
2330
def delete(self) -> None:
2431
"""Delete the audio.
2532

videodb/client.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ def get_collection(self, collection_id: Optional[str] = "default") -> Collection
5454
self.collection_id,
5555
collection_data.get("name"),
5656
collection_data.get("description"),
57+
collection_data.get("is_public", False),
5758
)
5859

5960
def get_collections(self) -> List[Collection]:
@@ -69,15 +70,19 @@ def get_collections(self) -> List[Collection]:
6970
collection.get("id"),
7071
collection.get("name"),
7172
collection.get("description"),
73+
collection.get("is_public", False),
7274
)
7375
for collection in collections_data.get("collections")
7476
]
7577

76-
def create_collection(self, name: str, description: str) -> Collection:
78+
def create_collection(
79+
self, name: str, description: str, is_public: bool = False
80+
) -> Collection:
7781
"""Create a new collection.
7882
7983
:param name: Name of the collection
8084
:param description: Description of the collection
85+
:param is_public: Make collection public
8186
:return: :class:`Collection <Collection>` object
8287
:rtype: :class:`videodb.collection.Collection`
8388
"""
@@ -86,6 +91,7 @@ def create_collection(self, name: str, description: str) -> Collection:
8691
data={
8792
"name": name,
8893
"description": description,
94+
"is_public": is_public,
8995
},
9096
)
9197
self.collection_id = collection_data.get("id", "default")
@@ -94,6 +100,7 @@ def create_collection(self, name: str, description: str) -> Collection:
94100
collection_data.get("id"),
95101
collection_data.get("name"),
96102
collection_data.get("description"),
103+
collection_data.get("is_public", False),
97104
)
98105

99106
def update_collection(self, id: str, name: str, description: str) -> Collection:
@@ -118,6 +125,7 @@ def update_collection(self, id: str, name: str, description: str) -> Collection:
118125
collection_data.get("id"),
119126
collection_data.get("name"),
120127
collection_data.get("description"),
128+
collection_data.get("is_public", False),
121129
)
122130

123131
def check_usage(self) -> dict:
@@ -136,6 +144,15 @@ def get_invoices(self) -> List[dict]:
136144
"""
137145
return self.get(path=f"{ApiPath.billing}/{ApiPath.invoices}")
138146

147+
def download(self, stream_link: str, name: str) -> dict:
148+
return self.post(
149+
path=f"{ApiPath.download}",
150+
data={
151+
"stream_link": stream_link,
152+
"name": name,
153+
},
154+
)
155+
139156
def upload(
140157
self,
141158
file_path: str = None,

videodb/collection.py

Lines changed: 49 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
Optional,
55
Union,
66
List,
7+
Dict,
8+
Any,
79
)
810
from videodb._upload import (
911
upload,
@@ -24,20 +26,38 @@
2426
class Collection:
2527
"""Collection class to interact with the Collection"""
2628

27-
def __init__(self, _connection, id: str, name: str = None, description: str = None):
29+
def __init__(
30+
self,
31+
_connection,
32+
id: str,
33+
name: str = None,
34+
description: str = None,
35+
is_public: bool = False,
36+
):
2837
self._connection = _connection
2938
self.id = id
3039
self.name = name
3140
self.description = description
41+
self.is_public = is_public
3242

3343
def __repr__(self) -> str:
3444
return (
3545
f"Collection("
3646
f"id={self.id}, "
3747
f"name={self.name}, "
38-
f"description={self.description})"
48+
f"description={self.description}), "
49+
f"is_public={self.is_public})"
3950
)
4051

52+
def delete(self) -> None:
53+
"""Delete the collection
54+
55+
:raises InvalidRequestError: If the delete fails
56+
:return: None if the delete is successful
57+
:rtype: None
58+
"""
59+
self._connection.delete(path=f"{ApiPath.collection}/{self.id}")
60+
4161
def get_videos(self) -> List[Video]:
4262
"""Get all the videos in the collection.
4363
@@ -154,6 +174,7 @@ def search(
154174
result_threshold: Optional[int] = None,
155175
score_threshold: Optional[float] = None,
156176
dynamic_score_percentage: Optional[float] = None,
177+
filter: List[Dict[str, Any]] = [],
157178
) -> SearchResult:
158179
"""Search for a query in the collection.
159180
@@ -176,8 +197,22 @@ def search(
176197
result_threshold=result_threshold,
177198
score_threshold=score_threshold,
178199
dynamic_score_percentage=dynamic_score_percentage,
200+
filter=filter,
179201
)
180202

203+
def search_title(self, query) -> List[Video]:
204+
search_data = self._connection.post(
205+
path=f"{ApiPath.collection}/{self.id}/{ApiPath.search}/{ApiPath.title}",
206+
data={
207+
"query": query,
208+
"search_type": SearchType.llm,
209+
},
210+
)
211+
return [
212+
{"video": Video(self._connection, **result.get("video"))}
213+
for result in search_data
214+
]
215+
181216
def upload(
182217
self,
183218
file_path: str = None,
@@ -214,3 +249,15 @@ def upload(
214249
return Audio(self._connection, **upload_data)
215250
elif media_id.startswith("img-"):
216251
return Image(self._connection, **upload_data)
252+
253+
def make_public(self):
254+
self._connection.patch(
255+
path=f"{ApiPath.collection}/{self.id}", data={"is_public": True}
256+
)
257+
self.is_public = True
258+
259+
def make_private(self):
260+
self._connection.patch(
261+
path=f"{ApiPath.collection}/{self.id}", data={"is_public": False}
262+
)
263+
self.is_public = False

videodb/image.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,13 @@ def __repr__(self) -> str:
2020
f"url={self.url})"
2121
)
2222

23+
def generate_url(self) -> str:
24+
url_data = self._connection.post(
25+
path=f"{ApiPath.image}/{self.id}/{ApiPath.generate_url}",
26+
params={"collection_id": self.collection_id},
27+
)
28+
return url_data.get("signed_url", None)
29+
2330
def delete(self) -> None:
2431
"""Delete the image.
2532

0 commit comments

Comments
 (0)