pyezvizapi 1.0.0.1__py3-none-any.whl → 1.0.0.2__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,54 @@ class EzvizClient:
1368
1363
 
1369
1364
  return json_output["encryptkey"]
1370
1365
 
1366
+ def get_cam_auth_code(self, serial: str, max_retries: int = 0) -> Any:
1367
+ """Get Camera auth code. This is the verification code on the camera sticker."""
1368
+
1369
+ if max_retries > MAX_RETRIES:
1370
+ raise PyEzvizError("Can't gather proper data. Max retries exceeded.")
1371
+
1372
+ try:
1373
+ req = self._session.get(
1374
+ "https://"
1375
+ + self._token["api_url"]
1376
+ + API_ENDPOINT_CAM_AUTH_CODE
1377
+ + serial,
1378
+ params={
1379
+ "encrptPwd": "",
1380
+ "msgAuthCode": "",
1381
+ "senderType": 0,
1382
+ },
1383
+ timeout=self._timeout,
1384
+ )
1385
+
1386
+ req.raise_for_status()
1387
+
1388
+ except requests.HTTPError as err:
1389
+ if err.response.status_code == 401:
1390
+ # session is wrong, need to relogin
1391
+ self.login()
1392
+ return self.get_cam_auth_code(serial, max_retries + 1)
1393
+
1394
+ raise HTTPError from err
1395
+
1396
+ try:
1397
+ json_output = req.json()
1398
+
1399
+ except ValueError as err:
1400
+ raise PyEzvizError(
1401
+ "Impossible to decode response: "
1402
+ + str(err)
1403
+ + "\nResponse was: "
1404
+ + str(req.text)
1405
+ ) from err
1406
+
1407
+ if json_output["meta"]["code"] != 200:
1408
+ raise PyEzvizError(
1409
+ f"Could not get camera verification key: Got {json_output})"
1410
+ )
1411
+
1412
+ return json_output["devAuthCode"]
1413
+
1371
1414
  def create_panoramic(self, serial: str, max_retries: int = 0) -> Any:
1372
1415
  """Create panoramic image."""
1373
1416
 
@@ -2044,9 +2087,7 @@ class EzvizClient:
2044
2087
 
2045
2088
  def get_connection(self) -> Any:
2046
2089
  """Get ezviz connection infos filter."""
2047
- return self._api_get_pagelist(
2048
- page_filter="CONNECTION", json_key="CONNECTION"
2049
- )
2090
+ return self._api_get_pagelist(page_filter="CONNECTION", json_key="CONNECTION")
2050
2091
 
2051
2092
  def _get_status(self) -> Any:
2052
2093
  """Get ezviz status infos filter."""
@@ -2054,9 +2095,7 @@ class EzvizClient:
2054
2095
 
2055
2096
  def get_switch(self) -> Any:
2056
2097
  """Get ezviz switch infos filter."""
2057
- return self._api_get_pagelist(
2058
- page_filter="SWITCH", json_key="SWITCH"
2059
- )
2098
+ return self._api_get_pagelist(page_filter="SWITCH", json_key="SWITCH")
2060
2099
 
2061
2100
  def _get_wifi(self) -> Any:
2062
2101
  """Get ezviz wifi infos filter."""
@@ -2064,9 +2103,7 @@ class EzvizClient:
2064
2103
 
2065
2104
  def _get_nodisturb(self) -> Any:
2066
2105
  """Get ezviz nodisturb infos filter."""
2067
- return self._api_get_pagelist(
2068
- page_filter="NODISTURB", json_key="NODISTURB"
2069
- )
2106
+ return self._api_get_pagelist(page_filter="NODISTURB", json_key="NODISTURB")
2070
2107
 
2071
2108
  def _get_p2p(self) -> Any:
2072
2109
  """Get ezviz P2P infos filter."""
@@ -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.2
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
@@ -1,19 +1,19 @@
1
1
  pyezvizapi/__init__.py,sha256=2YnR6s7OOOpV8QfxI6hdBKfc6WFerT55jqV8A1tDRSs,1167
2
2
  pyezvizapi/__main__.py,sha256=a0JxEmkevYPmWK8V9cHt-7i8MtpztOl2IrrZ2SfEsrM,15718
3
- pyezvizapi/api_endpoints.py,sha256=RqfLIOzj7FkzdbIixjhkJajjzmyZmaLjkOxcTOq86n4,2242
3
+ pyezvizapi/api_endpoints.py,sha256=ZJ9rTfFOWVgxEZP3enaWwgiH4576eBLrVwiaOrLFvIQ,2303
4
4
  pyezvizapi/camera.py,sha256=asP-PNoRPWR2KdlBir2NtLy4UpsLdOXzh2KyRfsir9s,11008
5
5
  pyezvizapi/cas.py,sha256=d31ZflYSD9P40MnsNRNZbT0HVLvlnHokKpLbdAjWQ74,5631
6
- pyezvizapi/client.py,sha256=GLId80AGlc75RPzy34zXYd39m5M_QIow4pfLOQtJ-ww,68444
6
+ pyezvizapi/client.py,sha256=aXPxenDU3Pao7Zln4XPGslIIIo3waj8s9PInfznF-UE,69888
7
7
  pyezvizapi/constants.py,sha256=NWOsr57VIh3t_3it-d6hDVDYHEFiQ2MjupBj6FMte4Y,10049
8
8
  pyezvizapi/exceptions.py,sha256=TBJGh12s4UAMVY4k3jibfjEt9D4NVgKnv-397HmfEws,608
9
9
  pyezvizapi/light_bulb.py,sha256=harFSyhnowS9doFjUASI5fcIubE_buRg3c_J2jkY4ho,5028
10
10
  pyezvizapi/mqtt.py,sha256=Y4X99Z0Avm32SE8vog7CNsv6tGUPmPYUZUgPDGS0QJA,7866
11
11
  pyezvizapi/test_cam_rtsp.py,sha256=w7GPcYIeK78TxL8zFDihdGSDQNWcYrurwZOr6uFzzgo,4902
12
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,,
13
+ pyezvizapi-1.0.0.2.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
14
+ pyezvizapi-1.0.0.2.dist-info/LICENSE.md,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
15
+ pyezvizapi-1.0.0.2.dist-info/METADATA,sha256=0Ptacan7YaF3SICwuab-iB_ntNC-gDOXZW5P6CC_S6c,672
16
+ pyezvizapi-1.0.0.2.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
17
+ pyezvizapi-1.0.0.2.dist-info/entry_points.txt,sha256=_BSJ3eNb2H_AZkRdsv1s4mojqWn3N7m503ujvg1SudA,56
18
+ pyezvizapi-1.0.0.2.dist-info/top_level.txt,sha256=gMZTelIi8z7pXyTCQLLaIkxVRrDQ_lS2NEv0WgfHrHs,11
19
+ pyezvizapi-1.0.0.2.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