aioamazondevices 3.2.0__py3-none-any.whl → 3.2.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.
- aioamazondevices/__init__.py +1 -1
- aioamazondevices/api.py +21 -7
- aioamazondevices/const.py +1 -0
- {aioamazondevices-3.2.0.dist-info → aioamazondevices-3.2.2.dist-info}/METADATA +1 -1
- aioamazondevices-3.2.2.dist-info/RECORD +11 -0
- aioamazondevices-3.2.0.dist-info/RECORD +0 -11
- {aioamazondevices-3.2.0.dist-info → aioamazondevices-3.2.2.dist-info}/LICENSE +0 -0
- {aioamazondevices-3.2.0.dist-info → aioamazondevices-3.2.2.dist-info}/WHEEL +0 -0
aioamazondevices/__init__.py
CHANGED
aioamazondevices/api.py
CHANGED
@@ -32,6 +32,7 @@ from .const import (
|
|
32
32
|
AMAZON_DEVICE_TYPE,
|
33
33
|
BIN_EXTENSION,
|
34
34
|
CSRF_COOKIE,
|
35
|
+
DEFAULT_AGENT,
|
35
36
|
DEFAULT_ASSOC_HANDLE,
|
36
37
|
DEFAULT_HEADERS,
|
37
38
|
DEVICE_TO_IGNORE,
|
@@ -161,7 +162,17 @@ class AmazonEchoApi:
|
|
161
162
|
if not self._login_stored_data:
|
162
163
|
return {}
|
163
164
|
|
164
|
-
|
165
|
+
website_cookies: dict[str, Any] = self._login_stored_data["website_cookies"]
|
166
|
+
website_cookies.update(
|
167
|
+
{
|
168
|
+
"session-token": self._login_stored_data["store_authentication_cookie"][
|
169
|
+
"cookie"
|
170
|
+
]
|
171
|
+
}
|
172
|
+
)
|
173
|
+
website_cookies.update({"lc-acbit": self._language})
|
174
|
+
|
175
|
+
return website_cookies
|
165
176
|
|
166
177
|
def _serial_number(self) -> str:
|
167
178
|
"""Get or calculate device serial number."""
|
@@ -325,6 +336,7 @@ class AmazonEchoApi:
|
|
325
336
|
url: str,
|
326
337
|
input_data: dict[str, Any] | None = None,
|
327
338
|
json_data: bool = False,
|
339
|
+
amazon_user_agent: bool = True,
|
328
340
|
) -> tuple[BeautifulSoup, ClientResponse]:
|
329
341
|
"""Return request response context data."""
|
330
342
|
_LOGGER.debug(
|
@@ -337,7 +349,10 @@ class AmazonEchoApi:
|
|
337
349
|
|
338
350
|
headers = DEFAULT_HEADERS
|
339
351
|
headers.update({"Accept-Language": self._language})
|
340
|
-
if
|
352
|
+
if not amazon_user_agent:
|
353
|
+
_LOGGER.debug("Changing User-Agent to %s", DEFAULT_AGENT)
|
354
|
+
headers.update({"User-Agent": DEFAULT_AGENT})
|
355
|
+
if self._csrf_cookie:
|
341
356
|
csrf = {CSRF_COOKIE: self._csrf_cookie}
|
342
357
|
_LOGGER.debug("Adding <%s> to headers", csrf)
|
343
358
|
headers.update(csrf)
|
@@ -362,6 +377,9 @@ class AmazonEchoApi:
|
|
362
377
|
raise CannotConnect(f"Connection error during {method}") from exc
|
363
378
|
|
364
379
|
self._cookies.update(**await self._parse_cookies_from_headers(resp.headers))
|
380
|
+
if not self._csrf_cookie:
|
381
|
+
self._csrf_cookie = resp.cookies.get(CSRF_COOKIE, Morsel()).value
|
382
|
+
_LOGGER.debug("CSRF cookie value: <%s>", self._csrf_cookie)
|
365
383
|
|
366
384
|
content_type: str = resp.headers.get("Content-Type", "")
|
367
385
|
_LOGGER.debug(
|
@@ -556,6 +574,7 @@ class AmazonEchoApi:
|
|
556
574
|
_, raw_resp = await self._session_request(
|
557
575
|
"GET",
|
558
576
|
url=f"https://alexa.amazon.{self._domain}{URI_IDS}",
|
577
|
+
amazon_user_agent=False,
|
559
578
|
)
|
560
579
|
json_data = await raw_resp.json()
|
561
580
|
|
@@ -770,11 +789,6 @@ class AmazonEchoApi:
|
|
770
789
|
_LOGGER.debug("Response code: |%s|", response_code)
|
771
790
|
|
772
791
|
response_data = await raw_resp.text()
|
773
|
-
|
774
|
-
if not self._csrf_cookie:
|
775
|
-
self._csrf_cookie = raw_resp.cookies.get(CSRF_COOKIE, Morsel()).value
|
776
|
-
_LOGGER.debug("CSRF cookie value: <%s>", self._csrf_cookie)
|
777
|
-
|
778
792
|
json_data = {} if len(response_data) == 0 else await raw_resp.json()
|
779
793
|
|
780
794
|
_LOGGER.debug("JSON data: |%s|", scrub_fields(json_data))
|
aioamazondevices/const.py
CHANGED
@@ -86,6 +86,7 @@ DEFAULT_HEADERS = {
|
|
86
86
|
"Accept-Encoding": "gzip",
|
87
87
|
"Connection": "keep-alive",
|
88
88
|
}
|
89
|
+
DEFAULT_AGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36 Edg/138.0.0.0" # noqa: E501
|
89
90
|
CSRF_COOKIE = "csrf"
|
90
91
|
|
91
92
|
NODE_DEVICES = "devices"
|
@@ -0,0 +1,11 @@
|
|
1
|
+
aioamazondevices/__init__.py,sha256=qelvi3_OmLOGJDAwlKAmQe5biPKQ8p0sbMx3c2Tpif0,276
|
2
|
+
aioamazondevices/api.py,sha256=yIU0w95V9v7fDlArNK26azOtogBX8yxJJKBJbA_UWKs,39169
|
3
|
+
aioamazondevices/const.py,sha256=q2TlD1O4jPtQ-hIxCCZuD-uoXCFNudF11JSjSC2hClY,8687
|
4
|
+
aioamazondevices/exceptions.py,sha256=CfOFKDvE_yl5BFoFcpTOuDfgRi_2oAtKk-nNJgfWBAs,726
|
5
|
+
aioamazondevices/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
6
|
+
aioamazondevices/sounds.py,sha256=01pVCDFIuhrLypXInw4JNuHsC6zjMLsuKocet1R6we8,13409
|
7
|
+
aioamazondevices/utils.py,sha256=RzuKRhnq_8ymCoJMoQJ2vBYyuew06RSWpqQWmqdNczE,2019
|
8
|
+
aioamazondevices-3.2.2.dist-info/LICENSE,sha256=sS48k5sp9bFV-NSHDfAJuTZZ_-AP9ZDqUzQ9sffGlsg,11346
|
9
|
+
aioamazondevices-3.2.2.dist-info/METADATA,sha256=JIkelm9RwNWUra00wyvNp_wR09BNskKA-NFF013cbHU,5234
|
10
|
+
aioamazondevices-3.2.2.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
|
11
|
+
aioamazondevices-3.2.2.dist-info/RECORD,,
|
@@ -1,11 +0,0 @@
|
|
1
|
-
aioamazondevices/__init__.py,sha256=2bsaWXIfe39pE5Jjw25d1t7wCVNWK36dLG4zXoSQZpU,276
|
2
|
-
aioamazondevices/api.py,sha256=W4LyCmiWCSJlHzpTSAQkb8DMcZbBQxJufZ3lnSasiik,38648
|
3
|
-
aioamazondevices/const.py,sha256=J47aHAfoA6rRgHDvn-q_S4xp8MrC6O1rEk1ZeRnN-8E,8529
|
4
|
-
aioamazondevices/exceptions.py,sha256=CfOFKDvE_yl5BFoFcpTOuDfgRi_2oAtKk-nNJgfWBAs,726
|
5
|
-
aioamazondevices/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
6
|
-
aioamazondevices/sounds.py,sha256=01pVCDFIuhrLypXInw4JNuHsC6zjMLsuKocet1R6we8,13409
|
7
|
-
aioamazondevices/utils.py,sha256=RzuKRhnq_8ymCoJMoQJ2vBYyuew06RSWpqQWmqdNczE,2019
|
8
|
-
aioamazondevices-3.2.0.dist-info/LICENSE,sha256=sS48k5sp9bFV-NSHDfAJuTZZ_-AP9ZDqUzQ9sffGlsg,11346
|
9
|
-
aioamazondevices-3.2.0.dist-info/METADATA,sha256=7d6AfzuC3n4IVSV1FWk37dR_Ruej_mCc1coKc5KE_yY,5234
|
10
|
-
aioamazondevices-3.2.0.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
|
11
|
-
aioamazondevices-3.2.0.dist-info/RECORD,,
|
File without changes
|
File without changes
|