pyezvizapi 1.0.0.1__py3-none-any.whl → 1.0.0.3__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 pyezvizapi might be problematic. Click here for more details.

@@ -26,6 +26,7 @@ API_ENDPOINT_DETECTION_SENSIBILITY = "/api/device/configAlgorithm"
26
26
  API_ENDPOINT_DETECTION_SENSIBILITY_GET = "/api/device/queryAlgorithmConfig"
27
27
  API_ENDPOINT_SET_DEFENCE_SCHEDULE = "/api/device/defence/plan2"
28
28
  API_ENDPOINT_CAM_ENCRYPTKEY = "/api/device/query/encryptkey"
29
+ API_ENDPOINT_CAM_AUTH_CODE = "/v3/devconfig/authcode/query/"
29
30
  API_ENDPOINT_CANCEL_ALARM = "/api/device/cancelAlarm"
30
31
  API_ENDPOINT_DEVICE_SYS_OPERATION = "/api/device/v2/sysOper/"
31
32
  API_ENDPOINT_DEVICE_STORAGE_STATUS = "/api/device/queryStorageStatus"
pyezvizapi/client.py CHANGED
@@ -15,6 +15,7 @@ import requests
15
15
  from .api_endpoints import (
16
16
  API_ENDPOINT_ALARM_SOUND,
17
17
  API_ENDPOINT_ALARMINFO_GET,
18
+ API_ENDPOINT_CAM_AUTH_CODE,
18
19
  API_ENDPOINT_CAM_ENCRYPTKEY,
19
20
  API_ENDPOINT_CANCEL_ALARM,
20
21
  API_ENDPOINT_CHANGE_DEFENCE_STATUS,
@@ -340,7 +341,6 @@ class EzvizClient:
340
341
 
341
342
  return data
342
343
 
343
-
344
344
  def get_alarminfo(self, serial: str, limit: int = 1, max_retries: int = 0) -> dict:
345
345
  """Get data from alarm info API for camera serial."""
346
346
  if max_retries > MAX_RETRIES:
@@ -950,15 +950,11 @@ class EzvizClient:
950
950
  if max_retries > MAX_RETRIES:
951
951
  raise PyEzvizError("Can't gather proper data. Max retries exceeded.")
952
952
 
953
- device_token_info = self.get_user_id()
954
- cookies = {
955
- "clientType": "3",
956
- "clientVersion": "5.12.1.0517",
957
- "userId": device_token_info["userId"],
958
- "ASG_DisplayName": "home",
959
- "C_SS": self._session.headers["sessionId"],
960
- "lang": "en_US",
961
- }
953
+ if enable == 2 and not old_password:
954
+ raise PyEzvizError("Old password is required when changing password.")
955
+
956
+ if new_password and not enable == 2:
957
+ raise PyEzvizError("New password is only required when changing password.")
962
958
 
963
959
  try:
964
960
  req = self._session.put(
@@ -968,14 +964,13 @@ class EzvizClient:
968
964
  + API_ENDPOINT_VIDEO_ENCRYPT,
969
965
  data={
970
966
  "deviceSerial": serial,
971
- "isEncrypt": enable,
972
- "oldPassword": old_password,
967
+ "isEncrypt": enable, # 1 = enable, 0 = disable, 2 = change password
968
+ "oldPassword": old_password, # required if changing.
973
969
  "password": new_password,
974
970
  "featureCode": FEATURE_CODE,
975
971
  "validateCode": camera_verification_code,
976
972
  "msgType": -1,
977
973
  },
978
- cookies=cookies,
979
974
  timeout=self._timeout,
980
975
  )
981
976
 
@@ -1368,6 +1363,64 @@ class EzvizClient:
1368
1363
 
1369
1364
  return json_output["encryptkey"]
1370
1365
 
1366
+ def get_cam_auth_code(
1367
+ self,
1368
+ serial: str,
1369
+ encrypt_pwd: str | None = None,
1370
+ msg_auth_code: int | None = None,
1371
+ max_retries: int = 0,
1372
+ ) -> Any:
1373
+ """Get Camera auth code. This is the verification code on the camera sticker."""
1374
+
1375
+ if max_retries > MAX_RETRIES:
1376
+ raise PyEzvizError("Can't gather proper data. Max retries exceeded.")
1377
+
1378
+ params: dict[str, int | str | None] = {
1379
+ "encrptPwd": encrypt_pwd,
1380
+ "msgAuthCode": msg_auth_code,
1381
+ "senderType": 0,
1382
+ }
1383
+
1384
+ try:
1385
+ req = self._session.get(
1386
+ "https://"
1387
+ + self._token["api_url"]
1388
+ + API_ENDPOINT_CAM_AUTH_CODE
1389
+ + serial,
1390
+ params=params,
1391
+ timeout=self._timeout,
1392
+ )
1393
+
1394
+ req.raise_for_status()
1395
+
1396
+ except requests.HTTPError as err:
1397
+ if err.response.status_code == 401:
1398
+ # session is wrong, need to relogin
1399
+ self.login()
1400
+ return self.get_cam_auth_code(
1401
+ serial, encrypt_pwd, msg_auth_code, max_retries + 1
1402
+ )
1403
+
1404
+ raise HTTPError from err
1405
+
1406
+ try:
1407
+ json_output = req.json()
1408
+
1409
+ except ValueError as err:
1410
+ raise PyEzvizError(
1411
+ "Impossible to decode response: "
1412
+ + str(err)
1413
+ + "\nResponse was: "
1414
+ + str(req.text)
1415
+ ) from err
1416
+
1417
+ if json_output["meta"]["code"] != 200:
1418
+ raise PyEzvizError(
1419
+ f"Could not get camera verification key: Got {json_output})"
1420
+ )
1421
+
1422
+ return json_output["devAuthCode"]
1423
+
1371
1424
  def create_panoramic(self, serial: str, max_retries: int = 0) -> Any:
1372
1425
  """Create panoramic image."""
1373
1426
 
@@ -1720,7 +1773,7 @@ class EzvizClient:
1720
1773
  self,
1721
1774
  serial: str,
1722
1775
  enable: int = 1,
1723
- channelno: int = 1,
1776
+ channelno: str = "1",
1724
1777
  max_retries: int = 0,
1725
1778
  ) -> bool:
1726
1779
  """Set do not disturb on camera with specified serial."""
@@ -2044,9 +2097,7 @@ class EzvizClient:
2044
2097
 
2045
2098
  def get_connection(self) -> Any:
2046
2099
  """Get ezviz connection infos filter."""
2047
- return self._api_get_pagelist(
2048
- page_filter="CONNECTION", json_key="CONNECTION"
2049
- )
2100
+ return self._api_get_pagelist(page_filter="CONNECTION", json_key="CONNECTION")
2050
2101
 
2051
2102
  def _get_status(self) -> Any:
2052
2103
  """Get ezviz status infos filter."""
@@ -2054,9 +2105,7 @@ class EzvizClient:
2054
2105
 
2055
2106
  def get_switch(self) -> Any:
2056
2107
  """Get ezviz switch infos filter."""
2057
- return self._api_get_pagelist(
2058
- page_filter="SWITCH", json_key="SWITCH"
2059
- )
2108
+ return self._api_get_pagelist(page_filter="SWITCH", json_key="SWITCH")
2060
2109
 
2061
2110
  def _get_wifi(self) -> Any:
2062
2111
  """Get ezviz wifi infos filter."""
@@ -2064,9 +2113,7 @@ class EzvizClient:
2064
2113
 
2065
2114
  def _get_nodisturb(self) -> Any:
2066
2115
  """Get ezviz nodisturb infos filter."""
2067
- return self._api_get_pagelist(
2068
- page_filter="NODISTURB", json_key="NODISTURB"
2069
- )
2116
+ return self._api_get_pagelist(page_filter="NODISTURB", json_key="NODISTURB")
2070
2117
 
2071
2118
  def _get_p2p(self) -> Any:
2072
2119
  """Get ezviz P2P infos filter."""
pyezvizapi/light_bulb.py CHANGED
@@ -66,7 +66,7 @@ class EzvizLightBulb:
66
66
 
67
67
  return json_output
68
68
 
69
- def get_feature_item(self, key: str, default_value: Any = None) -> Any:
69
+ def get_feature_item(self, key: str, default_value: Any = { "dataValue" : "" }) -> Any:
70
70
  """Get items fron FEATURE."""
71
71
  items = self._feature_json["featureItemDtos"]
72
72
  for item in items:
pyezvizapi/utils.py CHANGED
@@ -114,7 +114,12 @@ def decrypt_image(input_data: bytes, password: str) -> bytes:
114
114
  return output_data
115
115
 
116
116
 
117
- def deep_merge(dict1, dict2):
117
+ def return_password_hash(password: str) -> str:
118
+ """Return the password hash."""
119
+ return md5(str.encode(md5(str.encode(password)).hexdigest())).hexdigest()
120
+
121
+
122
+ def deep_merge(dict1: Any, dict2: Any) -> Any:
118
123
  """Recursively merges two dictionaries, handling lists as well.
119
124
 
120
125
  Args:
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.2
2
2
  Name: pyezvizapi
3
- Version: 1.0.0.1
3
+ Version: 1.0.0.3
4
4
  Summary: Pilot your Ezviz cameras
5
5
  Home-page: https://github.com/RenierM26/pyEzvizApi/
6
6
  Author: Renier Moorcroft
@@ -14,5 +14,13 @@ Requires-Dist: pandas
14
14
  Requires-Dist: paho-mqtt
15
15
  Requires-Dist: xmltodict
16
16
  Requires-Dist: pycryptodome
17
+ Dynamic: author
18
+ Dynamic: author-email
19
+ Dynamic: description
20
+ Dynamic: home-page
21
+ Dynamic: license
22
+ Dynamic: requires-dist
23
+ Dynamic: requires-python
24
+ Dynamic: summary
17
25
 
18
26
  Pilot your Ezviz cameras with this module. Please view readme on github
@@ -0,0 +1,19 @@
1
+ pyezvizapi/__init__.py,sha256=2YnR6s7OOOpV8QfxI6hdBKfc6WFerT55jqV8A1tDRSs,1167
2
+ pyezvizapi/__main__.py,sha256=a0JxEmkevYPmWK8V9cHt-7i8MtpztOl2IrrZ2SfEsrM,15718
3
+ pyezvizapi/api_endpoints.py,sha256=ZJ9rTfFOWVgxEZP3enaWwgiH4576eBLrVwiaOrLFvIQ,2303
4
+ pyezvizapi/camera.py,sha256=asP-PNoRPWR2KdlBir2NtLy4UpsLdOXzh2KyRfsir9s,11008
5
+ pyezvizapi/cas.py,sha256=d31ZflYSD9P40MnsNRNZbT0HVLvlnHokKpLbdAjWQ74,5631
6
+ pyezvizapi/client.py,sha256=Tb8CQWQ1Jlwa5sGypOEj2rbpUyDP7PtcVIWQFmrtfH4,70111
7
+ pyezvizapi/constants.py,sha256=NWOsr57VIh3t_3it-d6hDVDYHEFiQ2MjupBj6FMte4Y,10049
8
+ pyezvizapi/exceptions.py,sha256=TBJGh12s4UAMVY4k3jibfjEt9D4NVgKnv-397HmfEws,608
9
+ pyezvizapi/light_bulb.py,sha256=2v92JEQuItC8rtjxTC6qyvJaBDlcsEiVNXcNyQRltpc,5044
10
+ pyezvizapi/mqtt.py,sha256=Y4X99Z0Avm32SE8vog7CNsv6tGUPmPYUZUgPDGS0QJA,7866
11
+ pyezvizapi/test_cam_rtsp.py,sha256=w7GPcYIeK78TxL8zFDihdGSDQNWcYrurwZOr6uFzzgo,4902
12
+ pyezvizapi/utils.py,sha256=5J10o3h-y8prWDvl3LSAF-9wS1jBgBMg5cpAEebcuSM,4936
13
+ pyezvizapi-1.0.0.3.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
14
+ pyezvizapi-1.0.0.3.dist-info/LICENSE.md,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
15
+ pyezvizapi-1.0.0.3.dist-info/METADATA,sha256=bDBDDH0uRwT5opvgxL7LMAG9Xr23YdtZHUibEwsaVOg,672
16
+ pyezvizapi-1.0.0.3.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
17
+ pyezvizapi-1.0.0.3.dist-info/entry_points.txt,sha256=_BSJ3eNb2H_AZkRdsv1s4mojqWn3N7m503ujvg1SudA,56
18
+ pyezvizapi-1.0.0.3.dist-info/top_level.txt,sha256=gMZTelIi8z7pXyTCQLLaIkxVRrDQ_lS2NEv0WgfHrHs,11
19
+ pyezvizapi-1.0.0.3.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (75.7.0)
2
+ Generator: setuptools (75.8.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,19 +0,0 @@
1
- pyezvizapi/__init__.py,sha256=2YnR6s7OOOpV8QfxI6hdBKfc6WFerT55jqV8A1tDRSs,1167
2
- pyezvizapi/__main__.py,sha256=a0JxEmkevYPmWK8V9cHt-7i8MtpztOl2IrrZ2SfEsrM,15718
3
- pyezvizapi/api_endpoints.py,sha256=RqfLIOzj7FkzdbIixjhkJajjzmyZmaLjkOxcTOq86n4,2242
4
- pyezvizapi/camera.py,sha256=asP-PNoRPWR2KdlBir2NtLy4UpsLdOXzh2KyRfsir9s,11008
5
- pyezvizapi/cas.py,sha256=d31ZflYSD9P40MnsNRNZbT0HVLvlnHokKpLbdAjWQ74,5631
6
- pyezvizapi/client.py,sha256=GLId80AGlc75RPzy34zXYd39m5M_QIow4pfLOQtJ-ww,68444
7
- pyezvizapi/constants.py,sha256=NWOsr57VIh3t_3it-d6hDVDYHEFiQ2MjupBj6FMte4Y,10049
8
- pyezvizapi/exceptions.py,sha256=TBJGh12s4UAMVY4k3jibfjEt9D4NVgKnv-397HmfEws,608
9
- pyezvizapi/light_bulb.py,sha256=harFSyhnowS9doFjUASI5fcIubE_buRg3c_J2jkY4ho,5028
10
- pyezvizapi/mqtt.py,sha256=Y4X99Z0Avm32SE8vog7CNsv6tGUPmPYUZUgPDGS0QJA,7866
11
- pyezvizapi/test_cam_rtsp.py,sha256=w7GPcYIeK78TxL8zFDihdGSDQNWcYrurwZOr6uFzzgo,4902
12
- pyezvizapi/utils.py,sha256=VKtxTVjreIybCp9EAhjJks6ySq4M0HsKpQAoBNDS2io,4755
13
- pyezvizapi-1.0.0.1.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
14
- pyezvizapi-1.0.0.1.dist-info/LICENSE.md,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
15
- pyezvizapi-1.0.0.1.dist-info/METADATA,sha256=_TISRVqLUCWjxfinPUUSrM0sr72RYofJWmDk0_DNe7s,512
16
- pyezvizapi-1.0.0.1.dist-info/WHEEL,sha256=A3WOREP4zgxI0fKrHUG8DC8013e3dK3n7a6HDbcEIwE,91
17
- pyezvizapi-1.0.0.1.dist-info/entry_points.txt,sha256=_BSJ3eNb2H_AZkRdsv1s4mojqWn3N7m503ujvg1SudA,56
18
- pyezvizapi-1.0.0.1.dist-info/top_level.txt,sha256=gMZTelIi8z7pXyTCQLLaIkxVRrDQ_lS2NEv0WgfHrHs,11
19
- pyezvizapi-1.0.0.1.dist-info/RECORD,,