aioamazondevices 6.4.4__py3-none-any.whl → 6.4.6__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.
Potentially problematic release.
This version of aioamazondevices might be problematic. Click here for more details.
- aioamazondevices/__init__.py +1 -1
- aioamazondevices/api.py +12 -2
- aioamazondevices/const.py +7 -6
- {aioamazondevices-6.4.4.dist-info → aioamazondevices-6.4.6.dist-info}/METADATA +1 -1
- aioamazondevices-6.4.6.dist-info/RECORD +12 -0
- aioamazondevices-6.4.4.dist-info/RECORD +0 -12
- {aioamazondevices-6.4.4.dist-info → aioamazondevices-6.4.6.dist-info}/WHEEL +0 -0
- {aioamazondevices-6.4.4.dist-info → aioamazondevices-6.4.6.dist-info}/licenses/LICENSE +0 -0
aioamazondevices/__init__.py
CHANGED
aioamazondevices/api.py
CHANGED
|
@@ -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:
|
|
@@ -940,8 +943,13 @@ class AmazonEchoApi:
|
|
|
940
943
|
await self._get_base_devices()
|
|
941
944
|
self._last_devices_refresh = datetime.now(UTC)
|
|
942
945
|
|
|
946
|
+
# Only refresh endpoint data if we have no endpoints yet
|
|
943
947
|
delta_endpoints = datetime.now(UTC) - self._last_endpoint_refresh
|
|
944
|
-
|
|
948
|
+
endpoint_refresh_needed = delta_endpoints >= timedelta(days=1)
|
|
949
|
+
endpoints_recently_checked = delta_endpoints < timedelta(minutes=30)
|
|
950
|
+
if (
|
|
951
|
+
not self._endpoints and not endpoints_recently_checked
|
|
952
|
+
) or endpoint_refresh_needed:
|
|
945
953
|
_LOGGER.debug(
|
|
946
954
|
"Refreshing endpoint data after %s",
|
|
947
955
|
str(timedelta(minutes=round(delta_endpoints.total_seconds() / 60))),
|
|
@@ -969,6 +977,7 @@ class AmazonEchoApi:
|
|
|
969
977
|
device.sensors["dnd"] = device_dnd
|
|
970
978
|
|
|
971
979
|
async def _set_device_endpoints_data(self) -> None:
|
|
980
|
+
"""Set device endpoint data."""
|
|
972
981
|
devices_endpoints = await self._get_devices_endpoint_data()
|
|
973
982
|
for serial_number in self._final_devices:
|
|
974
983
|
device_endpoint = devices_endpoints.get(serial_number, {})
|
|
@@ -1046,6 +1055,7 @@ class AmazonEchoApi:
|
|
|
1046
1055
|
_, raw_resp = await self._session_request(
|
|
1047
1056
|
method=HTTPMethod.GET,
|
|
1048
1057
|
url=f"https://alexa.amazon.{self._domain}/api/bootstrap?version=0",
|
|
1058
|
+
agent="Browser",
|
|
1049
1059
|
)
|
|
1050
1060
|
if raw_resp.status != HTTPStatus.OK:
|
|
1051
1061
|
_LOGGER.debug(
|
|
@@ -1253,7 +1263,7 @@ class AmazonEchoApi:
|
|
|
1253
1263
|
device: AmazonDevice,
|
|
1254
1264
|
message_body: str,
|
|
1255
1265
|
) -> None:
|
|
1256
|
-
"""Call Alexa.
|
|
1266
|
+
"""Call Alexa.TextCommand to issue command."""
|
|
1257
1267
|
return await self._send_message(
|
|
1258
1268
|
device, AmazonSequenceType.TextCommand, message_body
|
|
1259
1269
|
)
|
aioamazondevices/const.py
CHANGED
|
@@ -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
|
},
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
aioamazondevices/__init__.py,sha256=G3JnYhlhatrCtpn_93BQbFjsfMMhklpDM4ACRD_F0Jw,276
|
|
2
|
+
aioamazondevices/api.py,sha256=VaOGSfUmpy8hRF7vISGoalZbyn2RqRpelDN9LepkPbw,50685
|
|
3
|
+
aioamazondevices/const.py,sha256=BZTyUku94uQa50R1ZeXo1h585xgUNT_Pb7KAifjawWc,12266
|
|
4
|
+
aioamazondevices/exceptions.py,sha256=gRYrxNAJnrV6uRuMx5e76VMvtNKyceXd09q84pDBBrI,638
|
|
5
|
+
aioamazondevices/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
6
|
+
aioamazondevices/query.py,sha256=SKn-fXFUnXnCvmKd6IvAGdkFL7sBzhYBEAZ0aZ2ez9E,1800
|
|
7
|
+
aioamazondevices/sounds.py,sha256=CXMDk-KoKVFxBdVAw3MeOClqgpzcVDxvQhFOJp7qX-Y,1896
|
|
8
|
+
aioamazondevices/utils.py,sha256=RzuKRhnq_8ymCoJMoQJ2vBYyuew06RSWpqQWmqdNczE,2019
|
|
9
|
+
aioamazondevices-6.4.6.dist-info/METADATA,sha256=e7_GTeYgN9fJp_P4o2Spft3iE2oY78DDaQtpQlakT4c,7648
|
|
10
|
+
aioamazondevices-6.4.6.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
|
|
11
|
+
aioamazondevices-6.4.6.dist-info/licenses/LICENSE,sha256=sS48k5sp9bFV-NSHDfAJuTZZ_-AP9ZDqUzQ9sffGlsg,11346
|
|
12
|
+
aioamazondevices-6.4.6.dist-info/RECORD,,
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
aioamazondevices/__init__.py,sha256=RJKwkp9uAk9e7js3Pk8zK2QhdAUUkwRTFRnANkhba1E,276
|
|
2
|
-
aioamazondevices/api.py,sha256=D0rYuokOL84pOejK-0p47ixeaHIFWU1CI_Mk3pIr57E,50218
|
|
3
|
-
aioamazondevices/const.py,sha256=DPMKG-mWE2qOSFtOKz-FybOlNPdGti2a7hycLIWqHDc,12097
|
|
4
|
-
aioamazondevices/exceptions.py,sha256=gRYrxNAJnrV6uRuMx5e76VMvtNKyceXd09q84pDBBrI,638
|
|
5
|
-
aioamazondevices/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
6
|
-
aioamazondevices/query.py,sha256=SKn-fXFUnXnCvmKd6IvAGdkFL7sBzhYBEAZ0aZ2ez9E,1800
|
|
7
|
-
aioamazondevices/sounds.py,sha256=CXMDk-KoKVFxBdVAw3MeOClqgpzcVDxvQhFOJp7qX-Y,1896
|
|
8
|
-
aioamazondevices/utils.py,sha256=RzuKRhnq_8ymCoJMoQJ2vBYyuew06RSWpqQWmqdNczE,2019
|
|
9
|
-
aioamazondevices-6.4.4.dist-info/METADATA,sha256=s7Ky3nRqiRh6ajdgvMJxd3Kz8nc1PmuYbevZFOU0n3k,7648
|
|
10
|
-
aioamazondevices-6.4.4.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
|
|
11
|
-
aioamazondevices-6.4.4.dist-info/licenses/LICENSE,sha256=sS48k5sp9bFV-NSHDfAJuTZZ_-AP9ZDqUzQ9sffGlsg,11346
|
|
12
|
-
aioamazondevices-6.4.4.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|