Skip to content
This repository was archived by the owner on Nov 20, 2024. It is now read-only.

Commit 100575f

Browse files
committed
Add Recording methods and Recorder setters
1 parent 3b07c6f commit 100575f

3 files changed

Lines changed: 153 additions & 3 deletions

File tree

examples/testusecase.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ async def use_case_list_of_recordings():
9494
print("Last 3 accessed via children property: ")
9595
for child in g3.recordings.children[:3]:
9696
print(child.uuid)
97-
await g3.recordings.stop_children_handlers()
97+
await g3.recordings.stop_children_handler_tasks()
9898

9999

100100
async def use_case_rudimentary_streams():

src/glasses3/recorder.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,13 @@ async def get_folder(self) -> JSONObject:
3131
self.generate_endpoint_uri(EndpointKind.PROPERTY, "folder")
3232
)
3333

34-
# async def set_folder(self):
34+
async def set_folder(self, value: str) -> bool:
35+
return cast(
36+
bool,
37+
await self._connection.require_post(
38+
self.generate_endpoint_uri(EndpointKind.PROPERTY, "folder"), body=value
39+
),
40+
)
3541

3642
async def get_gaze_overlay(self) -> JSONObject:
3743
return await self._connection.require_get(
@@ -73,6 +79,15 @@ async def get_visible_name(self) -> JSONObject:
7379
self.generate_endpoint_uri(EndpointKind.PROPERTY, "visible-name")
7480
)
7581

82+
async def set_visible_name(self, value: str) -> bool:
83+
return cast(
84+
bool,
85+
await self._connection.require_post(
86+
self.generate_endpoint_uri(EndpointKind.PROPERTY, "visible-name"),
87+
body=value,
88+
),
89+
)
90+
7691
async def cancel(self):
7792
await self._connection.require_post(
7893
self.generate_endpoint_uri(EndpointKind.ACTION, "cancel")

src/glasses3/recordings/recording.py

Lines changed: 136 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1+
from datetime import datetime
2+
from typing import List, cast
3+
14
from glasses3.g3typing import URI
2-
from glasses3.utils import APIComponent
5+
from glasses3.utils import APIComponent, EndpointKind
36
from glasses3.websocket import G3WebSocketClientProtocol
47

58

@@ -14,3 +17,135 @@ def __init__(
1417
@property
1518
def uuid(self):
1619
return self._uuid
20+
21+
async def get_created(self) -> datetime:
22+
created = cast(
23+
str,
24+
await self._connection.require_get(
25+
self.generate_endpoint_uri(EndpointKind.PROPERTY, "created")
26+
),
27+
)
28+
return datetime.fromisoformat(created.strip("Z"))
29+
30+
async def get_duration(self) -> float:
31+
return cast(
32+
float,
33+
await self._connection.require_get(
34+
self.generate_endpoint_uri(EndpointKind.PROPERTY, "duration")
35+
),
36+
)
37+
38+
async def get_folder(self) -> str:
39+
return cast(
40+
str,
41+
await self._connection.require_get(
42+
self.generate_endpoint_uri(EndpointKind.PROPERTY, "folder")
43+
),
44+
)
45+
46+
async def get_gaze_overlay(self) -> bool:
47+
return cast(
48+
bool,
49+
await self._connection.require_get(
50+
self.generate_endpoint_uri(EndpointKind.PROPERTY, "gaze-overlay")
51+
),
52+
)
53+
54+
async def get_gaze_samples(self) -> int:
55+
return cast(
56+
int,
57+
await self._connection.require_get(
58+
self.generate_endpoint_uri(EndpointKind.PROPERTY, "gaze-samples")
59+
),
60+
)
61+
62+
async def get_http_path(self) -> str:
63+
return cast(
64+
str,
65+
await self._connection.require_get(
66+
self.generate_endpoint_uri(EndpointKind.PROPERTY, "http-path")
67+
),
68+
)
69+
70+
async def get_name(self) -> str:
71+
return cast(
72+
str,
73+
await self._connection.require_get(
74+
self.generate_endpoint_uri(EndpointKind.PROPERTY, "name")
75+
),
76+
)
77+
78+
async def get_rtsp_path(self) -> str:
79+
return cast(
80+
str,
81+
await self._connection.require_get(
82+
self.generate_endpoint_uri(EndpointKind.PROPERTY, "rtsp-path")
83+
),
84+
)
85+
86+
async def get_timezone(self) -> str:
87+
return cast(
88+
str,
89+
await self._connection.require_get(
90+
self.generate_endpoint_uri(EndpointKind.PROPERTY, "timezone")
91+
),
92+
)
93+
94+
async def get_valid_gaze_samples(self) -> int:
95+
return cast(
96+
int,
97+
await self._connection.require_get(
98+
self.generate_endpoint_uri(EndpointKind.PROPERTY, "valid-gaze-samples")
99+
),
100+
)
101+
102+
async def get_visible_name(self) -> str:
103+
return cast(
104+
str,
105+
await self._connection.require_get(
106+
self.generate_endpoint_uri(EndpointKind.PROPERTY, "visible-name")
107+
),
108+
)
109+
110+
async def set_visible_name(self, value: str) -> bool:
111+
return cast(
112+
bool,
113+
await self._connection.require_post(
114+
self.generate_endpoint_uri(EndpointKind.PROPERTY, "visible-name"),
115+
body=value,
116+
),
117+
)
118+
119+
async def meta_insert(self, key: str, meta: str) -> bool:
120+
return cast(
121+
bool,
122+
await self._connection.require_post(
123+
self.generate_endpoint_uri(EndpointKind.ACTION, "meta-insert"),
124+
body=[key, meta],
125+
),
126+
)
127+
128+
async def meta_keys(self) -> List[str]:
129+
return cast(
130+
List[str],
131+
await self._connection.require_post(
132+
self.generate_endpoint_uri(EndpointKind.ACTION, "meta-keys")
133+
),
134+
)
135+
136+
async def meta_lookup(self, key: str) -> str:
137+
return cast(
138+
str,
139+
await self._connection.require_post(
140+
self.generate_endpoint_uri(EndpointKind.ACTION, "meta-lookup"),
141+
body=[key],
142+
),
143+
)
144+
145+
async def move(self, folder: str) -> bool:
146+
return cast(
147+
bool,
148+
await self._connection.require_post(
149+
self.generate_endpoint_uri(EndpointKind.ACTION, "move"), body=[folder]
150+
),
151+
)

0 commit comments

Comments
 (0)