uiprotect 7.15.0__py3-none-any.whl → 7.16.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of uiprotect might be problematic. Click here for more details.

uiprotect/api.py CHANGED
@@ -1519,6 +1519,14 @@ class ProtectApiClient(BaseApiClient):
1519
1519
  raise_exception=False,
1520
1520
  )
1521
1521
 
1522
+ async def get_public_api_camera_snapshot(self, camera_id: str) -> bytes | None:
1523
+ """Gets snapshot for a camera using public api."""
1524
+ return await self.api_request_raw(
1525
+ public_api=True,
1526
+ url=f"v1/cameras/{camera_id}/snapshot",
1527
+ params={"highQuality": "true"},
1528
+ )
1529
+
1522
1530
  async def get_package_camera_snapshot(
1523
1531
  self,
1524
1532
  camera_id: str,
@@ -2089,15 +2097,9 @@ class ProtectApiClient(BaseApiClient):
2089
2097
  if not name:
2090
2098
  raise BadRequest("API key name cannot be empty")
2091
2099
 
2092
- user_id = None
2093
- if self._last_token_cookie_decode is not None:
2094
- user_id = self._last_token_cookie_decode.get("userId")
2095
- if not user_id:
2096
- raise BadRequest("User ID not available for API key creation")
2097
-
2098
2100
  response = await self.api_request(
2099
2101
  api_path="/proxy/users/api/v2",
2100
- url=f"/user/{user_id}/keys",
2102
+ url="/user/self/keys",
2101
2103
  method="post",
2102
2104
  json={"name": name},
2103
2105
  )
uiprotect/data/devices.py CHANGED
@@ -2085,6 +2085,13 @@ class Camera(ProtectMotionDeviceModel):
2085
2085
 
2086
2086
  return await self._api.get_camera_snapshot(self.id, width, height, dt=dt)
2087
2087
 
2088
+ async def get_public_api_snapshot(self) -> bytes | None:
2089
+ """Gets snapshot for camera using public API."""
2090
+ if self._api._api_key is None:
2091
+ raise NotAuthorized("Cannot get public API snapshot without an API key.")
2092
+
2093
+ return await self._api.get_public_api_camera_snapshot(self.id)
2094
+
2088
2095
  async def get_package_snapshot(
2089
2096
  self,
2090
2097
  width: int | None = None,
@@ -325,6 +325,15 @@ class SampleDataGenerator:
325
325
  snapshot = await self.client.get_camera_snapshot(obj["id"], width, height)
326
326
  await self.write_image_file(filename, snapshot)
327
327
 
328
+ # public api snapshot
329
+ pub_filename = "sample_camera_public_api_snapshot"
330
+ if self.anonymize:
331
+ self.log(f"Writing {pub_filename}...")
332
+ placeholder_image(self.output_folder / f"{pub_filename}.png", width, height)
333
+ else:
334
+ pub_snapshot = await self.client.get_public_api_camera_snapshot(obj["id"])
335
+ await self.write_image_file(pub_filename, pub_snapshot)
336
+
328
337
  async def generate_motion_data(
329
338
  self,
330
339
  motion_event: dict[str, Any] | None,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: uiprotect
3
- Version: 7.15.0
3
+ Version: 7.16.0
4
4
  Summary: Python API for Unifi Protect (Unofficial)
5
5
  License: MIT
6
6
  Author: UI Protect Maintainers
@@ -1,7 +1,7 @@
1
1
  uiprotect/__init__.py,sha256=Oz6i1tonIz4QWVnEPkbielJDJ3WQdwZVgYtjY4IwGAQ,636
2
2
  uiprotect/__main__.py,sha256=C_bHCOkv5qj6WMy-6ELoY3Y6HDhLxOa1a30CzmbZhsg,462
3
3
  uiprotect/_compat.py,sha256=HThmb1zQZCEssCxYYbQzFhJq8zYYlVaSnIEZabKc-6U,302
4
- uiprotect/api.py,sha256=9n0iMjds9sSBShURytvlJezNMD-LL3T8E0OzPX243a8,73640
4
+ uiprotect/api.py,sha256=7eg1CoTV9sgnUcm9WnusXon3ltWOA_SuCbTxfmNY68Y,73711
5
5
  uiprotect/cli/__init__.py,sha256=rVfmLd4Al4-FQZxq7QrYlfr46fBGZv6Aw5huFtmCn58,9707
6
6
  uiprotect/cli/aiports.py,sha256=wpEr2w_hY18CGpFiQM2Yc0FiVwG_1l2CzZhZLGNigvI,1576
7
7
  uiprotect/cli/backup.py,sha256=9Coo5K4YTvQIrvGVZ-NYUajGnoMIyPhK_juxQxNkdO0,36761
@@ -19,7 +19,7 @@ uiprotect/data/__init__.py,sha256=audwJBjxRiYdNPeYlP6iofFIOq3gyQzh6VpDsOCM2dQ,29
19
19
  uiprotect/data/base.py,sha256=CXIxaJCJNpavadn6uF7vlhI4wxkfD8MNBGgR-smRA7k,35401
20
20
  uiprotect/data/bootstrap.py,sha256=r0T1qD6ZFC86pWK-70kx5MxugrN31XqVxUQ6BfB78O4,23552
21
21
  uiprotect/data/convert.py,sha256=xEN878_hm0HZZCVYGwJSxcSp2as9zpkvsemVIibReOA,2628
22
- uiprotect/data/devices.py,sha256=akNyLQKCNI8SiA7oUW1cSvE-IZ9Oav8iv9PfESpjits,115839
22
+ uiprotect/data/devices.py,sha256=WIMlVIsX2XafcB1GFwoCocTf5KBagPgNLWWsPtjnM54,116155
23
23
  uiprotect/data/nvr.py,sha256=HnknmMmUxe1aPA0PHJZSiEwpvo1phtHBp3wXsU6v_iI,46681
24
24
  uiprotect/data/types.py,sha256=PIf08tkkLzLPu8IHlEfv5Jqy7sdyhcbLkBgoV21Kyv0,19313
25
25
  uiprotect/data/user.py,sha256=Del5LUmt5uCfAQMI9-kl_GaKm085oTLjxmcCrlEKXxc,10526
@@ -28,12 +28,12 @@ uiprotect/exceptions.py,sha256=kgn0cRM6lTtgLza09SDa3ZiX6ue1QqHCOogQ4qu6KTQ,965
28
28
  uiprotect/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
29
29
  uiprotect/release_cache.json,sha256=NamnSFy78hOWY0DPO87J9ELFCAN6NnVquv8gQO75ZG4,386
30
30
  uiprotect/stream.py,sha256=ls65vMOXF4IlJ5axewFITfhcaTh_ihaFeCkCTfhy0Nk,5168
31
- uiprotect/test_util/__init__.py,sha256=TLTQrqyuLcIxp7bZTk3nIZ0U9znoMTLu7QyxrJKaLo0,19377
31
+ uiprotect/test_util/__init__.py,sha256=O22HGFX5Mb0j9LPzO48tm4ZqZTqGVBHo0jnye2FdT_I,19803
32
32
  uiprotect/test_util/anonymize.py,sha256=f-8ijU-_y9r-uAbhIPn0f0I6hzJpAkvJzc8UpWihObI,8478
33
33
  uiprotect/utils.py,sha256=2fLwXN0oz9dcVTFexzLp8jj97lcYrxLZkeEUGf5ehtU,20587
34
34
  uiprotect/websocket.py,sha256=tEyenqblNXHcjWYuf4oRP1E7buNwx6zoECMwpBr-jig,8191
35
- uiprotect-7.15.0.dist-info/LICENSE,sha256=INx18jhdbVXMEiiBANeKEbrbz57ckgzxk5uutmmcxGk,1111
36
- uiprotect-7.15.0.dist-info/METADATA,sha256=aR6aiVRJwN58_dEeklFE6Uq9wEdFxHOmt_sk5CIZYa4,11167
37
- uiprotect-7.15.0.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
38
- uiprotect-7.15.0.dist-info/entry_points.txt,sha256=J78AUTPrTTxgI3s7SVgrmGqDP7piX2wuuEORzhDdVRA,47
39
- uiprotect-7.15.0.dist-info/RECORD,,
35
+ uiprotect-7.16.0.dist-info/LICENSE,sha256=INx18jhdbVXMEiiBANeKEbrbz57ckgzxk5uutmmcxGk,1111
36
+ uiprotect-7.16.0.dist-info/METADATA,sha256=nX5HtYYpHiqVVuKo19MPKSOzG163q8prcUWufzaXzYY,11167
37
+ uiprotect-7.16.0.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
38
+ uiprotect-7.16.0.dist-info/entry_points.txt,sha256=J78AUTPrTTxgI3s7SVgrmGqDP7piX2wuuEORzhDdVRA,47
39
+ uiprotect-7.16.0.dist-info/RECORD,,