aioamazondevices 3.2.2__tar.gz → 3.2.4__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.
- {aioamazondevices-3.2.2 → aioamazondevices-3.2.4}/PKG-INFO +1 -1
- {aioamazondevices-3.2.2 → aioamazondevices-3.2.4}/pyproject.toml +1 -1
- {aioamazondevices-3.2.2 → aioamazondevices-3.2.4}/src/aioamazondevices/__init__.py +1 -1
- {aioamazondevices-3.2.2 → aioamazondevices-3.2.4}/src/aioamazondevices/api.py +24 -6
- {aioamazondevices-3.2.2 → aioamazondevices-3.2.4}/src/aioamazondevices/const.py +4 -0
- {aioamazondevices-3.2.2 → aioamazondevices-3.2.4}/LICENSE +0 -0
- {aioamazondevices-3.2.2 → aioamazondevices-3.2.4}/README.md +0 -0
- {aioamazondevices-3.2.2 → aioamazondevices-3.2.4}/src/aioamazondevices/exceptions.py +0 -0
- {aioamazondevices-3.2.2 → aioamazondevices-3.2.4}/src/aioamazondevices/py.typed +0 -0
- {aioamazondevices-3.2.2 → aioamazondevices-3.2.4}/src/aioamazondevices/sounds.py +0 -0
- {aioamazondevices-3.2.2 → aioamazondevices-3.2.4}/src/aioamazondevices/utils.py +0 -0
@@ -39,6 +39,8 @@ from .const import (
|
|
39
39
|
DEVICE_TYPE_TO_MODEL,
|
40
40
|
DOMAIN_BY_ISO3166_COUNTRY,
|
41
41
|
HTML_EXTENSION,
|
42
|
+
HTTP_ERROR_199,
|
43
|
+
HTTP_ERROR_299,
|
42
44
|
JSON_EXTENSION,
|
43
45
|
NODE_BLUETOOTH,
|
44
46
|
NODE_DEVICES,
|
@@ -148,9 +150,15 @@ class AmazonEchoApi:
|
|
148
150
|
self.session: ClientSession
|
149
151
|
self._devices: dict[str, Any] = {}
|
150
152
|
|
151
|
-
|
152
|
-
|
153
|
-
|
153
|
+
if locale and (lang := locale.get("language")):
|
154
|
+
language = lang
|
155
|
+
else:
|
156
|
+
lang_object = Language.make(territory=self._login_country_code.upper())
|
157
|
+
lang_maximized = lang_object.maximize()
|
158
|
+
language = f"{lang_maximized.language}-{lang_maximized.region}"
|
159
|
+
|
160
|
+
self._language = language
|
161
|
+
|
154
162
|
_LOGGER.debug(
|
155
163
|
"Initialize library with domain <%s> and language <%s>",
|
156
164
|
self._domain,
|
@@ -330,6 +338,16 @@ class AmazonEchoApi:
|
|
330
338
|
)
|
331
339
|
return False
|
332
340
|
|
341
|
+
async def _http_phrase_error(self, error: int) -> str:
|
342
|
+
"""Convert numeric error in human phrase."""
|
343
|
+
if error == HTTP_ERROR_199:
|
344
|
+
return "Miscellaneous Warning"
|
345
|
+
|
346
|
+
if error == HTTP_ERROR_299:
|
347
|
+
return "Miscellaneous Persistent Warning"
|
348
|
+
|
349
|
+
return HTTPStatus(error).phrase
|
350
|
+
|
333
351
|
async def _session_request(
|
334
352
|
self,
|
335
353
|
method: str,
|
@@ -395,10 +413,10 @@ class AmazonEchoApi:
|
|
395
413
|
HTTPStatus.PROXY_AUTHENTICATION_REQUIRED,
|
396
414
|
HTTPStatus.UNAUTHORIZED,
|
397
415
|
]:
|
398
|
-
raise CannotAuthenticate(
|
416
|
+
raise CannotAuthenticate(self._http_phrase_error(resp.status))
|
399
417
|
if not await self._ignore_ap_signin_error(resp):
|
400
418
|
raise CannotRetrieveData(
|
401
|
-
f"Request failed: {
|
419
|
+
f"Request failed: {self._http_phrase_error(resp.status)}"
|
402
420
|
)
|
403
421
|
|
404
422
|
await self._save_to_file(
|
@@ -509,7 +527,7 @@ class AmazonEchoApi:
|
|
509
527
|
obfuscate_email(self._login_email),
|
510
528
|
msg,
|
511
529
|
)
|
512
|
-
raise CannotRegisterDevice(f"{
|
530
|
+
raise CannotRegisterDevice(f"{self._http_phrase_error(resp.status)}: {msg}")
|
513
531
|
|
514
532
|
success_response = resp_json["response"]["success"]
|
515
533
|
|
@@ -6,6 +6,9 @@ _LOGGER = logging.getLogger(__package__)
|
|
6
6
|
|
7
7
|
DEFAULT_ASSOC_HANDLE = "amzn_dp_project_dee_ios"
|
8
8
|
|
9
|
+
HTTP_ERROR_199 = 199
|
10
|
+
HTTP_ERROR_299 = 299
|
11
|
+
|
9
12
|
TO_REDACT = {
|
10
13
|
"address",
|
11
14
|
"address1",
|
@@ -34,6 +37,7 @@ DOMAIN_BY_ISO3166_COUNTRY = {
|
|
34
37
|
},
|
35
38
|
"at": {
|
36
39
|
"domain": "de",
|
40
|
+
"language": "en-US",
|
37
41
|
"openid.assoc_handle": f"{DEFAULT_ASSOC_HANDLE}_de",
|
38
42
|
},
|
39
43
|
"au": {
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|