aioamazondevices 3.2.10__py3-none-any.whl → 3.3.1__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 +9 -30
- aioamazondevices/const.py +2 -2
- {aioamazondevices-3.2.10.dist-info → aioamazondevices-3.3.1.dist-info}/METADATA +2 -2
- aioamazondevices-3.3.1.dist-info/RECORD +11 -0
- aioamazondevices-3.2.10.dist-info/RECORD +0 -11
- {aioamazondevices-3.2.10.dist-info → aioamazondevices-3.3.1.dist-info}/LICENSE +0 -0
- {aioamazondevices-3.2.10.dist-info → aioamazondevices-3.3.1.dist-info}/WHEEL +0 -0
aioamazondevices/__init__.py
CHANGED
aioamazondevices/api.py
CHANGED
@@ -9,16 +9,16 @@ from dataclasses import dataclass
|
|
9
9
|
from datetime import UTC, datetime, timedelta
|
10
10
|
from enum import StrEnum
|
11
11
|
from http import HTTPMethod, HTTPStatus
|
12
|
-
from http.cookies import Morsel
|
12
|
+
from http.cookies import Morsel
|
13
13
|
from pathlib import Path
|
14
14
|
from typing import Any, cast
|
15
15
|
from urllib.parse import parse_qs, urlencode
|
16
16
|
|
17
17
|
import orjson
|
18
|
-
from aiohttp import ClientConnectorError, ClientResponse, ClientSession
|
18
|
+
from aiohttp import ClientConnectorError, ClientResponse, ClientSession, CookieJar
|
19
19
|
from bs4 import BeautifulSoup, Tag
|
20
20
|
from langcodes import Language
|
21
|
-
from multidict import
|
21
|
+
from multidict import MultiDictProxy
|
22
22
|
from yarl import URL
|
23
23
|
|
24
24
|
from .const import (
|
@@ -305,29 +305,9 @@ class AmazonEchoApi:
|
|
305
305
|
"""Create HTTP client session."""
|
306
306
|
if not hasattr(self, "session") or self.session.closed:
|
307
307
|
_LOGGER.debug("Creating HTTP session (aiohttp)")
|
308
|
-
|
309
|
-
|
310
|
-
self.session = ClientSession(
|
311
|
-
headers=headers,
|
312
|
-
cookies=self._cookies,
|
313
|
-
)
|
314
|
-
|
315
|
-
async def _parse_cookies_from_headers(
|
316
|
-
self, headers: CIMultiDictProxy[str]
|
317
|
-
) -> dict[str, str]:
|
318
|
-
"""Parse cookies with a value from headers."""
|
319
|
-
cookies_with_value: dict[str, str] = {}
|
320
|
-
|
321
|
-
for value in headers.getall("Set-Cookie", ()):
|
322
|
-
cookie = SimpleCookie()
|
323
|
-
cookie.load(value)
|
324
|
-
|
325
|
-
for name, morsel in cookie.items():
|
326
|
-
if morsel.value and morsel.value not in ("-", ""):
|
327
|
-
cookies_with_value[name] = morsel.value
|
328
|
-
|
329
|
-
_LOGGER.debug("Cookies from headers: %s", cookies_with_value)
|
330
|
-
return cookies_with_value
|
308
|
+
cookie_jar = CookieJar()
|
309
|
+
cookie_jar.update_cookies(self._cookies)
|
310
|
+
self.session = ClientSession(cookie_jar=cookie_jar)
|
331
311
|
|
332
312
|
async def _ignore_ap_signin_error(self, response: ClientResponse) -> bool:
|
333
313
|
"""Return true if error is due to signin endpoint."""
|
@@ -382,29 +362,28 @@ class AmazonEchoApi:
|
|
382
362
|
headers.update({"User-Agent": DEFAULT_AGENT})
|
383
363
|
if self._csrf_cookie:
|
384
364
|
csrf = {CSRF_COOKIE: self._csrf_cookie}
|
385
|
-
_LOGGER.debug("Adding
|
365
|
+
_LOGGER.debug("Adding to headers: %s", csrf)
|
386
366
|
headers.update(csrf)
|
387
367
|
|
388
368
|
if json_data:
|
389
369
|
json_header = {"Content-Type": "application/json; charset=utf-8"}
|
390
|
-
_LOGGER.debug("Adding
|
370
|
+
_LOGGER.debug("Adding to headers: %s", json_header)
|
391
371
|
headers.update(json_header)
|
392
372
|
|
393
373
|
_cookies = (
|
394
374
|
self._load_website_cookies() if self._login_stored_data else self._cookies
|
395
375
|
)
|
376
|
+
self.session.cookie_jar.update_cookies(_cookies)
|
396
377
|
try:
|
397
378
|
resp = await self.session.request(
|
398
379
|
method,
|
399
380
|
URL(url, encoded=True),
|
400
381
|
data=input_data if not json_data else orjson.dumps(input_data),
|
401
|
-
cookies=_cookies,
|
402
382
|
headers=headers,
|
403
383
|
)
|
404
384
|
except (TimeoutError, ClientConnectorError) as exc:
|
405
385
|
raise CannotConnect(f"Connection error during {method}") from exc
|
406
386
|
|
407
|
-
self._cookies.update(**await self._parse_cookies_from_headers(resp.headers))
|
408
387
|
if not self._csrf_cookie:
|
409
388
|
self._csrf_cookie = resp.cookies.get(CSRF_COOKIE, Morsel()).value
|
410
389
|
_LOGGER.debug("CSRF cookie value: <%s>", self._csrf_cookie)
|
aioamazondevices/const.py
CHANGED
@@ -42,7 +42,7 @@ DOMAIN_BY_ISO3166_COUNTRY = {
|
|
42
42
|
},
|
43
43
|
"au": {
|
44
44
|
"domain": "com.au",
|
45
|
-
"openid.assoc_handle": DEFAULT_ASSOC_HANDLE,
|
45
|
+
"openid.assoc_handle": f"{DEFAULT_ASSOC_HANDLE}_au",
|
46
46
|
},
|
47
47
|
"be": {
|
48
48
|
"domain": "com.be",
|
@@ -66,7 +66,7 @@ DOMAIN_BY_ISO3166_COUNTRY = {
|
|
66
66
|
},
|
67
67
|
"nz": {
|
68
68
|
"domain": "com.au",
|
69
|
-
"openid.assoc_handle": DEFAULT_ASSOC_HANDLE,
|
69
|
+
"openid.assoc_handle": f"{DEFAULT_ASSOC_HANDLE}_au",
|
70
70
|
},
|
71
71
|
"tr": {
|
72
72
|
"domain": "com.tr",
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.3
|
2
2
|
Name: aioamazondevices
|
3
|
-
Version: 3.
|
3
|
+
Version: 3.3.1
|
4
4
|
Summary: Python library to control Amazon devices
|
5
5
|
License: Apache-2.0
|
6
6
|
Author: Simone Chemelli
|
@@ -11,7 +11,7 @@ Classifier: Intended Audience :: Developers
|
|
11
11
|
Classifier: Natural Language :: English
|
12
12
|
Classifier: Operating System :: OS Independent
|
13
13
|
Classifier: Topic :: Software Development :: Libraries
|
14
|
-
Requires-Dist: aiohttp
|
14
|
+
Requires-Dist: aiohttp (>=3.12.7)
|
15
15
|
Requires-Dist: beautifulsoup4
|
16
16
|
Requires-Dist: colorlog
|
17
17
|
Requires-Dist: langcodes
|
@@ -0,0 +1,11 @@
|
|
1
|
+
aioamazondevices/__init__.py,sha256=Dgok2Xxu-FJDmSIfY-mQcaI6Xe1dCMQXfyyXYUVu4-c,276
|
2
|
+
aioamazondevices/api.py,sha256=4r1VMWkuk8GCVtrHlNq8Wvscl_ThscglHjuZyHgOm9U,39885
|
3
|
+
aioamazondevices/const.py,sha256=NVqS6TKQGlJJoViG9Mw9_dsKKyDL7v61OHHyjjkCqeY,9059
|
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.3.1.dist-info/LICENSE,sha256=sS48k5sp9bFV-NSHDfAJuTZZ_-AP9ZDqUzQ9sffGlsg,11346
|
9
|
+
aioamazondevices-3.3.1.dist-info/METADATA,sha256=hOfbN_9Bb0dMcvlOhsiwUAcbxxMa_MkMmGC_GGIF9bM,5245
|
10
|
+
aioamazondevices-3.3.1.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
|
11
|
+
aioamazondevices-3.3.1.dist-info/RECORD,,
|
@@ -1,11 +0,0 @@
|
|
1
|
-
aioamazondevices/__init__.py,sha256=-Ar_mvX5S_358fTLtKk3D2qoFUXnyf4K_jQ-uSuX4kk,277
|
2
|
-
aioamazondevices/api.py,sha256=a8VNFKe_eU4xoc0sCF7GTsEdEFvzjzdWpbsDeYzf1bU,40665
|
3
|
-
aioamazondevices/const.py,sha256=1TTqejdLJVB-8fBODXx4Ha9dxiQnuLVjbWusJ7WILdo,9043
|
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.10.dist-info/LICENSE,sha256=sS48k5sp9bFV-NSHDfAJuTZZ_-AP9ZDqUzQ9sffGlsg,11346
|
9
|
-
aioamazondevices-3.2.10.dist-info/METADATA,sha256=QzUzTQA62DVSsDnGshjApO9iPw0OM90KvmBSnJE2rvk,5235
|
10
|
-
aioamazondevices-3.2.10.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
|
11
|
-
aioamazondevices-3.2.10.dist-info/RECORD,,
|
File without changes
|
File without changes
|