pynintendoparental 1.0.3__tar.gz → 1.0.5__tar.gz

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.
Files changed (26) hide show
  1. {pynintendoparental-1.0.3 → pynintendoparental-1.0.5}/PKG-INFO +2 -2
  2. {pynintendoparental-1.0.3 → pynintendoparental-1.0.5}/pynintendoparental/__init__.py +10 -3
  3. pynintendoparental-1.0.5/pynintendoparental/_version.py +1 -0
  4. {pynintendoparental-1.0.3 → pynintendoparental-1.0.5}/pynintendoparental/api.py +1 -1
  5. {pynintendoparental-1.0.3 → pynintendoparental-1.0.5}/pynintendoparental/authenticator/__init__.py +6 -5
  6. {pynintendoparental-1.0.3 → pynintendoparental-1.0.5}/pynintendoparental/const.py +3 -3
  7. pynintendoparental-1.0.5/pynintendoparental/exceptions.py +21 -0
  8. {pynintendoparental-1.0.3 → pynintendoparental-1.0.5}/pynintendoparental.egg-info/PKG-INFO +2 -2
  9. {pynintendoparental-1.0.3 → pynintendoparental-1.0.5}/pynintendoparental.egg-info/requires.txt +1 -1
  10. {pynintendoparental-1.0.3 → pynintendoparental-1.0.5}/setup.py +1 -1
  11. pynintendoparental-1.0.3/pynintendoparental/_version.py +0 -1
  12. pynintendoparental-1.0.3/pynintendoparental/exceptions.py +0 -13
  13. {pynintendoparental-1.0.3 → pynintendoparental-1.0.5}/LICENSE +0 -0
  14. {pynintendoparental-1.0.3 → pynintendoparental-1.0.5}/README.md +0 -0
  15. {pynintendoparental-1.0.3 → pynintendoparental-1.0.5}/pynintendoparental/application.py +0 -0
  16. {pynintendoparental-1.0.3 → pynintendoparental-1.0.5}/pynintendoparental/authenticator/const.py +0 -0
  17. {pynintendoparental-1.0.3 → pynintendoparental-1.0.5}/pynintendoparental/device.py +0 -0
  18. {pynintendoparental-1.0.3 → pynintendoparental-1.0.5}/pynintendoparental/enum.py +0 -0
  19. {pynintendoparental-1.0.3 → pynintendoparental-1.0.5}/pynintendoparental/player.py +0 -0
  20. {pynintendoparental-1.0.3 → pynintendoparental-1.0.5}/pynintendoparental/py.typed +0 -0
  21. {pynintendoparental-1.0.3 → pynintendoparental-1.0.5}/pynintendoparental/utils.py +0 -0
  22. {pynintendoparental-1.0.3 → pynintendoparental-1.0.5}/pynintendoparental.egg-info/SOURCES.txt +0 -0
  23. {pynintendoparental-1.0.3 → pynintendoparental-1.0.5}/pynintendoparental.egg-info/dependency_links.txt +0 -0
  24. {pynintendoparental-1.0.3 → pynintendoparental-1.0.5}/pynintendoparental.egg-info/top_level.txt +0 -0
  25. {pynintendoparental-1.0.3 → pynintendoparental-1.0.5}/pyproject.toml +0 -0
  26. {pynintendoparental-1.0.3 → pynintendoparental-1.0.5}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pynintendoparental
3
- Version: 1.0.3
3
+ Version: 1.0.5
4
4
  Summary: A Python module to interact with Nintendo Parental Controls
5
5
  Home-page: http://github.com/pantherale0/pynintendoparental
6
6
  Author: pantherale0
@@ -14,7 +14,7 @@ License-File: LICENSE
14
14
  Provides-Extra: dev
15
15
  Requires-Dist: bandit<1.9,>=1.7; extra == "dev"
16
16
  Requires-Dist: black<26,>=23; extra == "dev"
17
- Requires-Dist: build<1.3,>=0.10; extra == "dev"
17
+ Requires-Dist: build<1.4,>=0.10; extra == "dev"
18
18
  Requires-Dist: flake8<8,>=6; extra == "dev"
19
19
  Requires-Dist: isort<7,>=5; extra == "dev"
20
20
  Requires-Dist: mypy<1.18,>=1.5; extra == "dev"
@@ -3,6 +3,8 @@
3
3
 
4
4
  import asyncio
5
5
 
6
+ from pynintendoparental.exceptions import HttpException, NoDevicesFoundException
7
+
6
8
  from .authenticator import Authenticator
7
9
  from .api import Api
8
10
  from .const import _LOGGER
@@ -29,9 +31,14 @@ class NintendoParental:
29
31
  _LOGGER.exception("Error updating device %s: %s",
30
32
  dev.device_id,
31
33
  err)
32
-
33
- response = await self._api.async_get_account_devices()
34
-
34
+ try:
35
+ response = await self._api.async_get_account_devices()
36
+ except HttpException as err:
37
+ if err.status_code == 404:
38
+ _LOGGER.error("No devices found for account %s", self.account_id)
39
+ raise NoDevicesFoundException("No devices found for account") from err
40
+ _LOGGER.error("Error fetching devices: %s", err)
41
+ raise
35
42
  for dev_raw in response["json"]["ownedDevices"]:
36
43
  device: Device = Device.from_device_response(dev_raw, self._api)
37
44
  if self.devices.get(device.device_id, None) is None:
@@ -0,0 +1 @@
1
+ __version__ = "1.0.5"
@@ -97,7 +97,7 @@ class Api:
97
97
  resp["json"] = {}
98
98
  resp["headers"] = response.headers
99
99
  else:
100
- raise HttpException("HTTP Error", response.status, await response.text())
100
+ raise HttpException(response.status, await response.text())
101
101
 
102
102
  # now return the resp dict
103
103
  return resp
@@ -140,7 +140,8 @@ class Authenticator:
140
140
  )
141
141
 
142
142
  if session_token_response.get("status") != 200:
143
- raise HttpException(f"login error {session_token_response.get('status')}")
143
+ raise HttpException(session_token_response.get("status"),
144
+ session_token_response.get("text"))
144
145
 
145
146
  self._session_token = session_token_response["json"]["session_token"]
146
147
 
@@ -158,13 +159,13 @@ class Authenticator:
158
159
  )
159
160
 
160
161
  if token_response["status"] == 400:
161
- raise InvalidSessionTokenException(token_response["json"]["error"])
162
+ raise InvalidSessionTokenException(400, token_response["json"]["error"])
162
163
 
163
164
  if token_response["status"] == 401:
164
- raise InvalidOAuthConfigurationException(token_response["json"]["error"])
165
+ raise InvalidOAuthConfigurationException(401, token_response["json"]["error"])
165
166
 
166
167
  if token_response.get("status") != 200:
167
- raise HttpException(f"login error {token_response.get('status')}")
168
+ raise HttpException(token_response.get("status"), f"login error {token_response.get('status')}")
168
169
 
169
170
  self._read_tokens(token_response.get("json"))
170
171
  if self.account_id is None:
@@ -177,7 +178,7 @@ class Authenticator:
177
178
  }
178
179
  )
179
180
  if account["status"] != 200:
180
- raise HttpException(f"Unable to get account_id {token_response.get('status')}")
181
+ raise HttpException(account["status"], f"Unable to get account_id {account['status']}")
181
182
  self.account_id = account["json"]["id"]
182
183
  self.account = account["json"]
183
184
 
@@ -5,10 +5,10 @@ import logging
5
5
 
6
6
  _LOGGER = logging.getLogger(__package__)
7
7
  MOBILE_APP_PKG = "com.nintendo.znma"
8
- MOBILE_APP_VERSION = "2.1.1"
9
- MOBILE_APP_BUILD = "540"
8
+ MOBILE_APP_VERSION = "2.2.0"
9
+ MOBILE_APP_BUILD = "560"
10
10
  OS_NAME = "ANDROID"
11
- OS_VERSION = "33"
11
+ OS_VERSION = "34"
12
12
  OS_STR = f"{OS_NAME} {OS_VERSION}"
13
13
  DEVICE_MODEL = "Pixel 4 XL"
14
14
  BASE_URL = "https://app.lp1.znma.srv.nintendo.net/v2"
@@ -0,0 +1,21 @@
1
+ """Nintendo Parental exceptions."""
2
+
3
+ class HttpException(Exception):
4
+ """A HTTP error occured"""
5
+ def __init__(self, status_code: int, message: str) -> None:
6
+ """Initialize the exception."""
7
+ super().__init__(message)
8
+ self.status_code = status_code
9
+ self.message = message
10
+
11
+ def __str__(self) -> str:
12
+ return f"HTTP {self.status_code}: {self.message}"
13
+
14
+ class InvalidSessionTokenException(HttpException):
15
+ """Provided session token was invalid (invalid_grant)."""
16
+
17
+ class InvalidOAuthConfigurationException(HttpException):
18
+ """The OAuth scopes are invalid."""
19
+
20
+ class NoDevicesFoundException(Exception):
21
+ """No devices were found for the account."""
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pynintendoparental
3
- Version: 1.0.3
3
+ Version: 1.0.5
4
4
  Summary: A Python module to interact with Nintendo Parental Controls
5
5
  Home-page: http://github.com/pantherale0/pynintendoparental
6
6
  Author: pantherale0
@@ -14,7 +14,7 @@ License-File: LICENSE
14
14
  Provides-Extra: dev
15
15
  Requires-Dist: bandit<1.9,>=1.7; extra == "dev"
16
16
  Requires-Dist: black<26,>=23; extra == "dev"
17
- Requires-Dist: build<1.3,>=0.10; extra == "dev"
17
+ Requires-Dist: build<1.4,>=0.10; extra == "dev"
18
18
  Requires-Dist: flake8<8,>=6; extra == "dev"
19
19
  Requires-Dist: isort<7,>=5; extra == "dev"
20
20
  Requires-Dist: mypy<1.18,>=1.5; extra == "dev"
@@ -2,7 +2,7 @@
2
2
  [dev]
3
3
  bandit<1.9,>=1.7
4
4
  black<26,>=23
5
- build<1.3,>=0.10
5
+ build<1.4,>=0.10
6
6
  flake8<8,>=6
7
7
  isort<7,>=5
8
8
  mypy<1.18,>=1.5
@@ -21,7 +21,7 @@ REQUIREMENTS = [
21
21
  DEV_REQUIREMENTS = [
22
22
  'bandit >= 1.7,< 1.9',
23
23
  'black >= 23,< 26',
24
- 'build >= 0.10,< 1.3',
24
+ 'build >= 0.10,< 1.4',
25
25
  'flake8 >= 6,< 8',
26
26
  'isort >= 5,< 7',
27
27
  'mypy >= 1.5,< 1.18',
@@ -1 +0,0 @@
1
- __version__ = "1.0.3"
@@ -1,13 +0,0 @@
1
- """Nintendo Parental exceptions."""
2
-
3
- class HttpException(Exception):
4
- """A HTTP error occured"""
5
-
6
- def __init__(self, *args: object) -> None:
7
- super().__init__("HTTP Exception", *args)
8
-
9
- class InvalidSessionTokenException(HttpException):
10
- """Provided session token was invalid (invalid_grant)."""
11
-
12
- class InvalidOAuthConfigurationException(HttpException):
13
- """The OAuth scopes are invalid."""