Skip to content

Commit bf02b6a

Browse files
committed
Put scene index id and name of shots in search result at doc level and introduce metadata
1 parent 163921e commit bf02b6a

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

videodb/search.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@ 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")
3937
for doc in result.get("docs"):
4038
self.shots.append(
4139
Shot(
@@ -47,8 +45,9 @@ def _format_results(self):
4745
doc.get("end"),
4846
doc.get("text"),
4947
doc.get("score"),
50-
scene_index_id=scene_index_id,
51-
scene_index_name=scene_index_name,
48+
scene_index_id=doc.get("scene_index_id"),
49+
scene_index_name=doc.get("scene_index_name"),
50+
metadata=doc.get("metadata"),
5251
)
5352
)
5453

videodb/shot.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ class Shot:
2121
:ivar str player_url: URL to play the shot in a player
2222
:ivar Optional[str] scene_index_id: ID of the scene index for scene search results
2323
:ivar Optional[str] scene_index_name: Name of the scene index for scene search results
24+
:ivar Optional[dict] metadata: Additional metadata for the shot
2425
"""
2526

2627
def __init__(
@@ -35,6 +36,8 @@ def __init__(
3536
search_score: Optional[int] = None,
3637
scene_index_id: Optional[str] = None,
3738
scene_index_name: Optional[str] = None,
39+
metadata: Optional[dict] = None,
40+
3841
) -> None:
3942
self._connection = _connection
4043
self.video_id = video_id
@@ -46,6 +49,7 @@ def __init__(
4649
self.search_score = search_score
4750
self.scene_index_id = scene_index_id
4851
self.scene_index_name = scene_index_name
52+
self.metadata = metadata
4953
self.stream_url = None
5054
self.player_url = None
5155

@@ -65,6 +69,9 @@ def __repr__(self) -> str:
6569
if self.scene_index_name:
6670
repr_str += f", scene_index_name={self.scene_index_name}"
6771

72+
if self.metadata:
73+
repr_str += f", metadata={self.metadata}"
74+
6875
repr_str += (
6976
f", stream_url={self.stream_url}, "
7077
f"player_url={self.player_url})"

0 commit comments

Comments
 (0)