aioamazondevices 3.2.1__py3-none-any.whl → 3.2.3__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.
@@ -1,6 +1,6 @@
1
1
  """aioamazondevices library."""
2
2
 
3
- __version__ = "3.2.1"
3
+ __version__ = "3.2.3"
4
4
 
5
5
 
6
6
  from .api import AmazonDevice, AmazonEchoApi
aioamazondevices/api.py CHANGED
@@ -148,9 +148,15 @@ class AmazonEchoApi:
148
148
  self.session: ClientSession
149
149
  self._devices: dict[str, Any] = {}
150
150
 
151
- lang_object = Language.make(territory=self._login_country_code.upper())
152
- lang_maximized = lang_object.maximize()
153
- self._language = f"{lang_maximized.language}-{lang_maximized.region}"
151
+ if locale and (lang := locale.get("language")):
152
+ language = lang
153
+ else:
154
+ lang_object = Language.make(territory=self._login_country_code.upper())
155
+ lang_maximized = lang_object.maximize()
156
+ language = f"{lang_maximized.language}-{lang_maximized.region}"
157
+
158
+ self._language = language
159
+
154
160
  _LOGGER.debug(
155
161
  "Initialize library with domain <%s> and language <%s>",
156
162
  self._domain,
@@ -352,7 +358,7 @@ class AmazonEchoApi:
352
358
  if not amazon_user_agent:
353
359
  _LOGGER.debug("Changing User-Agent to %s", DEFAULT_AGENT)
354
360
  headers.update({"User-Agent": DEFAULT_AGENT})
355
- if self._csrf_cookie and CSRF_COOKIE not in headers:
361
+ if self._csrf_cookie:
356
362
  csrf = {CSRF_COOKIE: self._csrf_cookie}
357
363
  _LOGGER.debug("Adding <%s> to headers", csrf)
358
364
  headers.update(csrf)
@@ -377,6 +383,9 @@ class AmazonEchoApi:
377
383
  raise CannotConnect(f"Connection error during {method}") from exc
378
384
 
379
385
  self._cookies.update(**await self._parse_cookies_from_headers(resp.headers))
386
+ if not self._csrf_cookie:
387
+ self._csrf_cookie = resp.cookies.get(CSRF_COOKIE, Morsel()).value
388
+ _LOGGER.debug("CSRF cookie value: <%s>", self._csrf_cookie)
380
389
 
381
390
  content_type: str = resp.headers.get("Content-Type", "")
382
391
  _LOGGER.debug(
@@ -786,11 +795,6 @@ class AmazonEchoApi:
786
795
  _LOGGER.debug("Response code: |%s|", response_code)
787
796
 
788
797
  response_data = await raw_resp.text()
789
-
790
- if not self._csrf_cookie:
791
- self._csrf_cookie = raw_resp.cookies.get(CSRF_COOKIE, Morsel()).value
792
- _LOGGER.debug("CSRF cookie value: <%s>", self._csrf_cookie)
793
-
794
798
  json_data = {} if len(response_data) == 0 else await raw_resp.json()
795
799
 
796
800
  _LOGGER.debug("JSON data: |%s|", scrub_fields(json_data))
aioamazondevices/const.py CHANGED
@@ -34,6 +34,7 @@ DOMAIN_BY_ISO3166_COUNTRY = {
34
34
  },
35
35
  "at": {
36
36
  "domain": "de",
37
+ "language": "en-US",
37
38
  "openid.assoc_handle": f"{DEFAULT_ASSOC_HANDLE}_de",
38
39
  },
39
40
  "au": {
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: aioamazondevices
3
- Version: 3.2.1
3
+ Version: 3.2.3
4
4
  Summary: Python library to control Amazon devices
5
5
  License: Apache-2.0
6
6
  Author: Simone Chemelli
@@ -0,0 +1,11 @@
1
+ aioamazondevices/__init__.py,sha256=ym9BWa7TjPo80kc9b_xrVPeW1cq_Xh_eDwduw3soMh4,276
2
+ aioamazondevices/api.py,sha256=3o64TiaYVq_kG5upZnOynmey2Ls7ZhH7xPigFykxq8Y,39309
3
+ aioamazondevices/const.py,sha256=iJ87rGFZi9FY8M-dPsFY3DNYltiJ_PCjlr4RxQtZlJQ,8716
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.3.dist-info/LICENSE,sha256=sS48k5sp9bFV-NSHDfAJuTZZ_-AP9ZDqUzQ9sffGlsg,11346
9
+ aioamazondevices-3.2.3.dist-info/METADATA,sha256=AZomsCQfXV4PWyyspc4PU1Xzq7HTeM7iRKbxzbU7yck,5234
10
+ aioamazondevices-3.2.3.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
11
+ aioamazondevices-3.2.3.dist-info/RECORD,,
@@ -1,11 +0,0 @@
1
- aioamazondevices/__init__.py,sha256=ylzOup7JB2cQ19iiOzvj0UaBpJlY2v4hV0fxxJyVeqo,276
2
- aioamazondevices/api.py,sha256=8wXIou_9WeFjbNS4_qPbQ8YFWUfN8EdIbivQ-UWSGDI,39218
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.1.dist-info/LICENSE,sha256=sS48k5sp9bFV-NSHDfAJuTZZ_-AP9ZDqUzQ9sffGlsg,11346
9
- aioamazondevices-3.2.1.dist-info/METADATA,sha256=qS7EZlIpIOa1F0BMNwW0Z3iAI_g5vFlXv3WSitr7NqI,5234
10
- aioamazondevices-3.2.1.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
11
- aioamazondevices-3.2.1.dist-info/RECORD,,