aioamazondevices 3.1.22__py3-none-any.whl → 3.1.23__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.1.22"
3
+ __version__ = "3.1.23"
4
4
 
5
5
 
6
6
  from .api import AmazonDevice, AmazonEchoApi
aioamazondevices/api.py CHANGED
@@ -146,6 +146,15 @@ class AmazonEchoApi:
146
146
  self.session: ClientSession
147
147
  self._devices: dict[str, Any] = {}
148
148
 
149
+ lang_object = Language.make(territory=self._login_country_code.upper())
150
+ lang_maximized = lang_object.maximize()
151
+ self._language = f"{lang_maximized.language}-{lang_maximized.region}"
152
+ _LOGGER.debug(
153
+ "Initialize library with domain <%s> and language <%s>",
154
+ self._domain,
155
+ self._language,
156
+ )
157
+
149
158
  def _load_website_cookies(self) -> dict[str, str]:
150
159
  """Get website cookies, if avaliables."""
151
160
  if not self._login_stored_data:
@@ -210,22 +219,23 @@ class AmazonEchoApi:
210
219
  code_challenge = self._create_s256_code_challenge(code_verifier)
211
220
 
212
221
  oauth_params = {
213
- "openid.oa2.response_type": "code",
214
- "openid.oa2.code_challenge_method": "S256",
215
- "openid.oa2.code_challenge": code_challenge,
216
222
  "openid.return_to": f"https://www.amazon.{self._domain}/ap/maplanding",
223
+ "openid.oa2.code_challenge_method": "S256",
217
224
  "openid.assoc_handle": self._assoc_handle,
218
225
  "openid.identity": "http://specs.openid.net/auth/2.0/identifier_select",
226
+ "pageId": self._assoc_handle,
219
227
  "accountStatusPolicy": "P1",
220
228
  "openid.claimed_id": "http://specs.openid.net/auth/2.0/identifier_select",
221
229
  "openid.mode": "checkid_setup",
222
230
  "openid.ns.oa2": "http://www.amazon.com/ap/ext/oauth/2",
223
231
  "openid.oa2.client_id": f"device:{client_id}",
232
+ "language": self._language.replace("-", "_"),
224
233
  "openid.ns.pape": "http://specs.openid.net/extensions/pape/1.0",
234
+ "openid.oa2.code_challenge": code_challenge,
225
235
  "openid.oa2.scope": "device_auth_access",
226
- "forceMobileLayout": "true",
227
236
  "openid.ns": "http://specs.openid.net/auth/2.0",
228
237
  "openid.pape.max_auth_age": "0",
238
+ "openid.oa2.response_type": "code",
229
239
  }
230
240
 
231
241
  return (
@@ -273,8 +283,10 @@ class AmazonEchoApi:
273
283
  """Create HTTP client session."""
274
284
  if not hasattr(self, "session") or self.session.closed:
275
285
  _LOGGER.debug("Creating HTTP session (aiohttp)")
286
+ headers = DEFAULT_HEADERS
287
+ headers.update({"Accept-Language": self._language})
276
288
  self.session = ClientSession(
277
- headers=DEFAULT_HEADERS,
289
+ headers=headers,
278
290
  cookies=self._cookies,
279
291
  )
280
292
 
@@ -323,6 +335,7 @@ class AmazonEchoApi:
323
335
  )
324
336
 
325
337
  headers = DEFAULT_HEADERS
338
+ headers.update({"Accept-Language": self._language})
326
339
  if self._csrf_cookie and CSRF_COOKIE not in headers:
327
340
  csrf = {CSRF_COOKIE: self._csrf_cookie}
328
341
  _LOGGER.debug("Adding <%s> to headers", csrf)
@@ -842,10 +855,6 @@ class AmazonEchoApi:
842
855
  message_source: AmazonMusicSource | None = None,
843
856
  ) -> None:
844
857
  """Send message to specific device."""
845
- lang_object = Language.make(territory=self._login_country_code.upper())
846
- lang_maximized = lang_object.maximize()
847
- locale = f"{lang_maximized.language}-{lang_maximized.region}"
848
-
849
858
  if not self._login_stored_data:
850
859
  _LOGGER.warning("Trying to send message before login")
851
860
  return
@@ -853,7 +862,7 @@ class AmazonEchoApi:
853
862
  base_payload = {
854
863
  "deviceType": device.device_type,
855
864
  "deviceSerialNumber": device.serial_number,
856
- "locale": locale,
865
+ "locale": self._language,
857
866
  "customerId": device.device_owner_customer_id,
858
867
  }
859
868
 
@@ -888,7 +897,7 @@ class AmazonEchoApi:
888
897
  "expireAfter": "PT5S",
889
898
  "content": [
890
899
  {
891
- "locale": locale,
900
+ "locale": self._language,
892
901
  "display": {
893
902
  "title": "Home Assistant",
894
903
  "body": message_body,
aioamazondevices/const.py CHANGED
@@ -84,7 +84,6 @@ DEFAULT_HEADERS = {
84
84
  ),
85
85
  "Accept-Charset": "utf-8",
86
86
  "Accept-Encoding": "gzip",
87
- "Accept-Language": "en-US",
88
87
  "Connection": "keep-alive",
89
88
  }
90
89
  CSRF_COOKIE = "csrf"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: aioamazondevices
3
- Version: 3.1.22
3
+ Version: 3.1.23
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=mZIaRiUx4hb3bx5kIhZc9PX7hxD-qnhod-h81ENTXac,277
2
+ aioamazondevices/api.py,sha256=J4e85fBrHIWPeTvP7TYsezvdHKQ0I_Pqz3HCcdmF6J8,37542
3
+ aioamazondevices/const.py,sha256=J47aHAfoA6rRgHDvn-q_S4xp8MrC6O1rEk1ZeRnN-8E,8529
4
+ aioamazondevices/exceptions.py,sha256=JDnSFi_7oEhqK31sHXf0S_cyMoMjiRJuLp4ow7mYgLY,643
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.1.23.dist-info/LICENSE,sha256=sS48k5sp9bFV-NSHDfAJuTZZ_-AP9ZDqUzQ9sffGlsg,11346
9
+ aioamazondevices-3.1.23.dist-info/METADATA,sha256=xEheLDnUfjp1pQbgAMvDsWmOcG5xnDnU8eZfmYSWg4A,5235
10
+ aioamazondevices-3.1.23.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
11
+ aioamazondevices-3.1.23.dist-info/RECORD,,
@@ -1,11 +0,0 @@
1
- aioamazondevices/__init__.py,sha256=1zTgfVFS9BIXxS-1ghlWzAXzlEs643PyJVEr2SeZxws,277
2
- aioamazondevices/api.py,sha256=6R7eHx48qRqWmLmC657R7vvED75mqS7WvCFh01ixLzk,37149
3
- aioamazondevices/const.py,sha256=w4tyAkGRbMX0s1NA1iOeuQ2yAB2v9Xqa56jLa4sQ9vg,8561
4
- aioamazondevices/exceptions.py,sha256=JDnSFi_7oEhqK31sHXf0S_cyMoMjiRJuLp4ow7mYgLY,643
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.1.22.dist-info/LICENSE,sha256=sS48k5sp9bFV-NSHDfAJuTZZ_-AP9ZDqUzQ9sffGlsg,11346
9
- aioamazondevices-3.1.22.dist-info/METADATA,sha256=NKuOQKxX6VK34vpsmrajPQlOa4b0pR-glSj3zaoKGiY,5235
10
- aioamazondevices-3.1.22.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
11
- aioamazondevices-3.1.22.dist-info/RECORD,,