aioamazondevices 3.1.22__tar.gz → 3.1.23__tar.gz
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-3.1.22 → aioamazondevices-3.1.23}/PKG-INFO +1 -1
- {aioamazondevices-3.1.22 → aioamazondevices-3.1.23}/pyproject.toml +1 -1
- {aioamazondevices-3.1.22 → aioamazondevices-3.1.23}/src/aioamazondevices/__init__.py +1 -1
- {aioamazondevices-3.1.22 → aioamazondevices-3.1.23}/src/aioamazondevices/api.py +20 -11
- {aioamazondevices-3.1.22 → aioamazondevices-3.1.23}/src/aioamazondevices/const.py +0 -1
- {aioamazondevices-3.1.22 → aioamazondevices-3.1.23}/LICENSE +0 -0
- {aioamazondevices-3.1.22 → aioamazondevices-3.1.23}/README.md +0 -0
- {aioamazondevices-3.1.22 → aioamazondevices-3.1.23}/src/aioamazondevices/exceptions.py +0 -0
- {aioamazondevices-3.1.22 → aioamazondevices-3.1.23}/src/aioamazondevices/py.typed +0 -0
- {aioamazondevices-3.1.22 → aioamazondevices-3.1.23}/src/aioamazondevices/sounds.py +0 -0
- {aioamazondevices-3.1.22 → aioamazondevices-3.1.23}/src/aioamazondevices/utils.py +0 -0
@@ -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=
|
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":
|
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":
|
900
|
+
"locale": self._language,
|
892
901
|
"display": {
|
893
902
|
"title": "Home Assistant",
|
894
903
|
"body": message_body,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|