Skip to content

Commit 163921e

Browse files
committed
Add scene index id and name in the shot of search response
1 parent 723fa12 commit 163921e

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

videodb/search.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ def __init__(self, _connection, **kwargs):
3434
def _format_results(self):
3535
for result in self._results:
3636
self.collection_id = result.get("collection_id")
37+
scene_index_id = result.get("scene_index_id")
38+
scene_index_name = result.get("scene_index_name")
3739
for doc in result.get("docs"):
3840
self.shots.append(
3941
Shot(
@@ -45,6 +47,8 @@ def _format_results(self):
4547
doc.get("end"),
4648
doc.get("text"),
4749
doc.get("score"),
50+
scene_index_id=scene_index_id,
51+
scene_index_name=scene_index_name,
4852
)
4953
)
5054

videodb/shot.py

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ class Shot:
1919
:ivar int search_score: Search relevance score
2020
:ivar str stream_url: URL to stream the shot
2121
:ivar str player_url: URL to play the shot in a player
22+
:ivar Optional[str] scene_index_id: ID of the scene index for scene search results
23+
:ivar Optional[str] scene_index_name: Name of the scene index for scene search results
2224
"""
2325

2426
def __init__(
@@ -31,6 +33,8 @@ def __init__(
3133
end: float,
3234
text: Optional[str] = None,
3335
search_score: Optional[int] = None,
36+
scene_index_id: Optional[str] = None,
37+
scene_index_name: Optional[str] = None,
3438
) -> None:
3539
self._connection = _connection
3640
self.video_id = video_id
@@ -40,21 +44,33 @@ def __init__(
4044
self.end = end
4145
self.text = text
4246
self.search_score = search_score
47+
self.scene_index_id = scene_index_id
48+
self.scene_index_name = scene_index_name
4349
self.stream_url = None
4450
self.player_url = None
4551

4652
def __repr__(self) -> str:
47-
return (
53+
repr_str = (
4854
f"Shot("
4955
f"video_id={self.video_id}, "
5056
f"video_title={self.video_title}, "
5157
f"start={self.start}, "
5258
f"end={self.end}, "
5359
f"text={self.text}, "
54-
f"search_score={self.search_score}, "
55-
f"stream_url={self.stream_url}, "
60+
f"search_score={self.search_score}"
61+
)
62+
if self.scene_index_id:
63+
repr_str += f", scene_index_id={self.scene_index_id}"
64+
65+
if self.scene_index_name:
66+
repr_str += f", scene_index_name={self.scene_index_name}"
67+
68+
repr_str += (
69+
f", stream_url={self.stream_url}, "
5670
f"player_url={self.player_url})"
5771
)
72+
return repr_str
73+
5874

5975
def __getitem__(self, key):
6076
"""Get an item from the shot object"""

0 commit comments

Comments
 (0)