aioamazondevices 6.4.3__tar.gz → 6.4.5__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.

Potentially problematic release.


This version of aioamazondevices might be problematic. Click here for more details.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: aioamazondevices
3
- Version: 6.4.3
3
+ Version: 6.4.5
4
4
  Summary: Python library to control Amazon devices
5
5
  License-Expression: Apache-2.0
6
6
  License-File: LICENSE
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "aioamazondevices"
3
- version = "6.4.3"
3
+ version = "6.4.5"
4
4
  requires-python = ">=3.12"
5
5
  description = "Python library to control Amazon devices"
6
6
  authors = [
@@ -1,6 +1,6 @@
1
1
  """aioamazondevices library."""
2
2
 
3
- __version__ = "6.4.3"
3
+ __version__ = "6.4.5"
4
4
 
5
5
 
6
6
  from .api import AmazonDevice, AmazonEchoApi
@@ -50,6 +50,7 @@ from .const import (
50
50
  JSON_EXTENSION,
51
51
  REFRESH_ACCESS_TOKEN,
52
52
  REFRESH_AUTH_COOKIES,
53
+ REQUEST_AGENT,
53
54
  SAVE_PATH,
54
55
  SENSORS,
55
56
  URI_DEVICES,
@@ -347,6 +348,7 @@ class AmazonEchoApi:
347
348
  url: str,
348
349
  input_data: dict[str, Any] | list[dict[str, Any]] | None = None,
349
350
  json_data: bool = False,
351
+ agent: str = "Amazon",
350
352
  ) -> tuple[BeautifulSoup, ClientResponse]:
351
353
  """Return request response context data."""
352
354
  _LOGGER.debug(
@@ -358,6 +360,7 @@ class AmazonEchoApi:
358
360
  )
359
361
 
360
362
  headers = DEFAULT_HEADERS.copy()
363
+ headers.update({"User-Agent": REQUEST_AGENT[agent]})
361
364
  headers.update({"Accept-Language": self._language})
362
365
 
363
366
  if self._csrf_cookie:
@@ -781,6 +784,10 @@ class AmazonEchoApi:
781
784
  self._login_stored_data.update({"site": f"https://www.amazon.{self._domain}"})
782
785
  await self._save_to_file(self._login_stored_data, "login_data", JSON_EXTENSION)
783
786
 
787
+ # Can take a little while to register device but we need it
788
+ # to be able to pickout account customer ID
789
+ await asyncio.sleep(2)
790
+
784
791
  return self._login_stored_data
785
792
 
786
793
  async def _login_mode_interactive_oauth(
@@ -1042,6 +1049,7 @@ class AmazonEchoApi:
1042
1049
  _, raw_resp = await self._session_request(
1043
1050
  method=HTTPMethod.GET,
1044
1051
  url=f"https://alexa.amazon.{self._domain}/api/bootstrap?version=0",
1052
+ agent="Browser",
1045
1053
  )
1046
1054
  if raw_resp.status != HTTPStatus.OK:
1047
1055
  _LOGGER.debug(
@@ -1249,7 +1257,7 @@ class AmazonEchoApi:
1249
1257
  device: AmazonDevice,
1250
1258
  message_body: str,
1251
1259
  ) -> None:
1252
- """Call Alexa.Sound to play sound."""
1260
+ """Call Alexa.TextCommand to issue command."""
1253
1261
  return await self._send_message(
1254
1262
  device, AmazonSequenceType.TextCommand, message_body
1255
1263
  )
@@ -39,14 +39,15 @@ AMAZON_CLIENT_OS = "18.5"
39
39
 
40
40
  DEFAULT_SITE = "https://www.amazon.com"
41
41
  DEFAULT_HEADERS = {
42
- "User-Agent": (
43
- f"AmazonWebView/AmazonAlexa/{AMAZON_APP_VERSION}/iOS/{AMAZON_CLIENT_OS}/iPhone"
44
- ),
45
42
  "Accept-Charset": "utf-8",
46
43
  "Accept-Encoding": "gzip",
47
44
  "Connection": "keep-alive",
48
45
  }
49
46
  CSRF_COOKIE = "csrf"
47
+ REQUEST_AGENT = {
48
+ "Amazon": f"AmazonWebView/AmazonAlexa/{AMAZON_APP_VERSION}/iOS/{AMAZON_CLIENT_OS}/iPhone", # noqa: E501
49
+ "Browser": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36 Edg/141.0.0.0", # noqa: E501
50
+ }
50
51
 
51
52
  REFRESH_ACCESS_TOKEN = "access_token" # noqa: S105
52
53
  REFRESH_AUTH_COOKIES = "auth_cookies"
@@ -184,7 +185,7 @@ DEVICE_TYPE_TO_MODEL: dict[str, dict[str, str | None]] = {
184
185
  "model": "Echo Dot",
185
186
  "hw_version": "Gen3",
186
187
  },
187
- "A1TD5Z1R8IWBHA ": {
188
+ "A1TD5Z1R8IWBHA": {
188
189
  "model": "Fire Tablet HD 8",
189
190
  "hw_version": "Gen12",
190
191
  },
@@ -235,7 +236,7 @@ DEVICE_TYPE_TO_MODEL: dict[str, dict[str, str | None]] = {
235
236
  "model": "Echo Dot Clock",
236
237
  "hw_version": "Gen5",
237
238
  },
238
- "A2E0SNTXJVT7WK ": {
239
+ "A2E0SNTXJVT7WK": {
239
240
  "model": "Fire TV Stick",
240
241
  "hw_version": "Gen2",
241
242
  },
@@ -319,7 +320,7 @@ DEVICE_TYPE_TO_MODEL: dict[str, dict[str, str | None]] = {
319
320
  "model": "Echo Dot",
320
321
  "hw_version": "Gen3",
321
322
  },
322
- "A33S43L213VSHQ ": {
323
+ "A33S43L213VSHQ": {
323
324
  "model": "Smart TV 4K",
324
325
  "hw_version": "4 Series",
325
326
  },