aioamazondevices 0.12.0__py3-none-any.whl → 1.0.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.
- aioamazondevices/__init__.py +1 -1
- aioamazondevices/api.py +10 -20
- aioamazondevices/const.py +2 -2
- {aioamazondevices-0.12.0.dist-info → aioamazondevices-1.0.0.dist-info}/METADATA +1 -1
- aioamazondevices-1.0.0.dist-info/RECORD +10 -0
- aioamazondevices-0.12.0.dist-info/RECORD +0 -10
- {aioamazondevices-0.12.0.dist-info → aioamazondevices-1.0.0.dist-info}/LICENSE +0 -0
- {aioamazondevices-0.12.0.dist-info → aioamazondevices-1.0.0.dist-info}/WHEEL +0 -0
aioamazondevices/__init__.py
CHANGED
aioamazondevices/api.py
CHANGED
@@ -2,7 +2,6 @@
|
|
2
2
|
|
3
3
|
import base64
|
4
4
|
import hashlib
|
5
|
-
import json
|
6
5
|
import mimetypes
|
7
6
|
import secrets
|
8
7
|
import uuid
|
@@ -29,7 +28,7 @@ from .const import (
|
|
29
28
|
AMAZON_DEVICE_TYPE,
|
30
29
|
DEFAULT_ASSOC_HANDLE,
|
31
30
|
DEFAULT_HEADERS,
|
32
|
-
|
31
|
+
DOMAIN_BY_ISO3166_COUNTRY,
|
33
32
|
HTML_EXTENSION,
|
34
33
|
JSON_EXTENSION,
|
35
34
|
NODE_BLUETOOTH,
|
@@ -66,14 +65,14 @@ class AmazonEchoApi:
|
|
66
65
|
login_country_code: str,
|
67
66
|
login_email: str,
|
68
67
|
login_password: str,
|
69
|
-
|
68
|
+
login_data: dict[str, Any] | None = None,
|
70
69
|
save_raw_data: bool = False,
|
71
70
|
) -> None:
|
72
71
|
"""Initialize the scanner."""
|
73
72
|
# Force country digits as lower case
|
74
73
|
country_code = login_country_code.lower()
|
75
74
|
|
76
|
-
locale =
|
75
|
+
locale = DOMAIN_BY_ISO3166_COUNTRY.get(country_code)
|
77
76
|
domain = locale["domain"] if locale else country_code
|
78
77
|
|
79
78
|
if locale and (assoc := locale.get("openid.assoc_handle")):
|
@@ -85,28 +84,15 @@ class AmazonEchoApi:
|
|
85
84
|
self._login_email = login_email
|
86
85
|
self._login_password = login_password
|
87
86
|
self._domain = domain
|
88
|
-
self._url = f"https://www.amazon.{domain}"
|
89
87
|
self._cookies = self._build_init_cookies()
|
90
88
|
self._headers = DEFAULT_HEADERS
|
91
89
|
self._save_raw_data = save_raw_data
|
92
|
-
self._login_stored_data
|
90
|
+
self._login_stored_data = login_data
|
93
91
|
self._serial = self._serial_number()
|
94
92
|
self._website_cookies: dict[str, Any] = self._load_website_cookies()
|
95
93
|
|
96
94
|
self.session: AsyncClient
|
97
95
|
|
98
|
-
def _load_data_file(self, data_file: str | None) -> dict[str, Any]:
|
99
|
-
"""Load stored login data from file."""
|
100
|
-
if not data_file or not (file := Path(data_file)).exists():
|
101
|
-
_LOGGER.debug(
|
102
|
-
"Cannot find previous login data file <%s>",
|
103
|
-
data_file,
|
104
|
-
)
|
105
|
-
return {}
|
106
|
-
|
107
|
-
with Path.open(file, "rb") as f:
|
108
|
-
return cast(dict[str, Any], json.load(f))
|
109
|
-
|
110
96
|
def _load_website_cookies(self) -> dict[str, Any]:
|
111
97
|
"""Get website cookies, if avaliables."""
|
112
98
|
if not self._login_stored_data:
|
@@ -248,7 +234,11 @@ class AmazonEchoApi:
|
|
248
234
|
cookies=self._website_cookies,
|
249
235
|
)
|
250
236
|
content_type: str = resp.headers.get("Content-Type", "")
|
251
|
-
_LOGGER.debug(
|
237
|
+
_LOGGER.debug(
|
238
|
+
"Response %s with content type: %s",
|
239
|
+
resp.status_code,
|
240
|
+
content_type,
|
241
|
+
)
|
252
242
|
|
253
243
|
await self._save_to_file(
|
254
244
|
resp.text,
|
@@ -266,7 +256,7 @@ class AmazonEchoApi:
|
|
266
256
|
output_path: str = SAVE_PATH,
|
267
257
|
) -> None:
|
268
258
|
"""Save response data to disk."""
|
269
|
-
if not self._save_raw_data:
|
259
|
+
if not self._save_raw_data or not raw_data:
|
270
260
|
return
|
271
261
|
|
272
262
|
output_dir = Path(output_path)
|
aioamazondevices/const.py
CHANGED
@@ -6,12 +6,12 @@ _LOGGER = logging.getLogger(__package__)
|
|
6
6
|
|
7
7
|
DEFAULT_ASSOC_HANDLE = "amzn_dp_project_dee_ios"
|
8
8
|
|
9
|
-
|
9
|
+
DOMAIN_BY_ISO3166_COUNTRY = {
|
10
10
|
"us": {
|
11
11
|
"domain": "com",
|
12
12
|
"openid.assoc_handle": DEFAULT_ASSOC_HANDLE,
|
13
13
|
},
|
14
|
-
"
|
14
|
+
"gb": {
|
15
15
|
"domain": "co.uk",
|
16
16
|
},
|
17
17
|
"au": {
|
@@ -0,0 +1,10 @@
|
|
1
|
+
aioamazondevices/__init__.py,sha256=XbJRDlStfKsLjiOzztTl_ZThVv3tQtDrUsHqBgQcUco,276
|
2
|
+
aioamazondevices/api.py,sha256=h3KtDQwERROb8HEkcnSY4pWpRWte3FRo70j_rtDxBUU,19407
|
3
|
+
aioamazondevices/auth.py,sha256=vLJh7iOEUYu-44WOvmrmZZueOcwz5dmHAGQmqs9fJME,10099
|
4
|
+
aioamazondevices/const.py,sha256=ikFYN9ZLAirnETkzOiuv-tJo6DYVDlEJyXWGRdbxI4A,1981
|
5
|
+
aioamazondevices/exceptions.py,sha256=qK_Hak9pc-lC2FPW-0i4rYIwNpEOHMmA9Rii8F2lkQo,1260
|
6
|
+
aioamazondevices/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
7
|
+
aioamazondevices-1.0.0.dist-info/LICENSE,sha256=sS48k5sp9bFV-NSHDfAJuTZZ_-AP9ZDqUzQ9sffGlsg,11346
|
8
|
+
aioamazondevices-1.0.0.dist-info/METADATA,sha256=0DhyVc7ZfnhIdGAJOsHxJ2_tC-Nq_H77wu98dRE7iZw,4742
|
9
|
+
aioamazondevices-1.0.0.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
|
10
|
+
aioamazondevices-1.0.0.dist-info/RECORD,,
|
@@ -1,10 +0,0 @@
|
|
1
|
-
aioamazondevices/__init__.py,sha256=oTQmfo7zpoQEBsdVdofolttfpX1O1x_nG2aDZlt_7wY,277
|
2
|
-
aioamazondevices/api.py,sha256=ZcCCvbljaDjteUFcnDOzixtYD6VTbELNubc4cMDWsBA,19831
|
3
|
-
aioamazondevices/auth.py,sha256=vLJh7iOEUYu-44WOvmrmZZueOcwz5dmHAGQmqs9fJME,10099
|
4
|
-
aioamazondevices/const.py,sha256=pY3CTWW8mOaWbaDV_oZunX9hGcDZIhImzTXZEf-mXDU,1973
|
5
|
-
aioamazondevices/exceptions.py,sha256=qK_Hak9pc-lC2FPW-0i4rYIwNpEOHMmA9Rii8F2lkQo,1260
|
6
|
-
aioamazondevices/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
7
|
-
aioamazondevices-0.12.0.dist-info/LICENSE,sha256=sS48k5sp9bFV-NSHDfAJuTZZ_-AP9ZDqUzQ9sffGlsg,11346
|
8
|
-
aioamazondevices-0.12.0.dist-info/METADATA,sha256=s3SMoDBFlSYDHLkjs7bsUAU1F6JAXfogkHU55SwjQ7w,4743
|
9
|
-
aioamazondevices-0.12.0.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
|
10
|
-
aioamazondevices-0.12.0.dist-info/RECORD,,
|
File without changes
|
File without changes
|