aioamazondevices 3.0.7__py3-none-any.whl → 3.0.9__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.
- aioamazondevices/__init__.py +1 -1
- aioamazondevices/api.py +25 -2
- aioamazondevices/const.py +2 -2
- aioamazondevices/exceptions.py +4 -0
- {aioamazondevices-3.0.7.dist-info → aioamazondevices-3.0.9.dist-info}/METADATA +1 -1
- aioamazondevices-3.0.9.dist-info/RECORD +10 -0
- aioamazondevices-3.0.7.dist-info/RECORD +0 -10
- {aioamazondevices-3.0.7.dist-info → aioamazondevices-3.0.9.dist-info}/LICENSE +0 -0
- {aioamazondevices-3.0.7.dist-info → aioamazondevices-3.0.9.dist-info}/WHEEL +0 -0
aioamazondevices/__init__.py
CHANGED
aioamazondevices/api.py
CHANGED
@@ -45,7 +45,12 @@ from .const import (
|
|
45
45
|
SAVE_PATH,
|
46
46
|
URI_QUERIES,
|
47
47
|
)
|
48
|
-
from .exceptions import
|
48
|
+
from .exceptions import (
|
49
|
+
CannotAuthenticate,
|
50
|
+
CannotRegisterDevice,
|
51
|
+
RequestFailed,
|
52
|
+
WrongMethod,
|
53
|
+
)
|
49
54
|
|
50
55
|
|
51
56
|
@dataclass
|
@@ -267,6 +272,14 @@ class AmazonEchoApi:
|
|
267
272
|
_LOGGER.debug("Cookies from headers: %s", cookies_with_value)
|
268
273
|
return cookies_with_value
|
269
274
|
|
275
|
+
async def _ignore_ap_sigin_error(self, response: ClientResponse) -> bool:
|
276
|
+
"""Return true if error is due to /ap/sigin endpoint."""
|
277
|
+
# Endpoint 'ap/sigin' replies with error 404
|
278
|
+
# but reports the needed parameters anyway
|
279
|
+
return (
|
280
|
+
response.status == HTTPStatus.NOT_FOUND and "/ap/sigin" in response.url.name
|
281
|
+
)
|
282
|
+
|
270
283
|
async def _session_request(
|
271
284
|
self,
|
272
285
|
method: str,
|
@@ -290,7 +303,7 @@ class AmazonEchoApi:
|
|
290
303
|
headers.update(csrf)
|
291
304
|
|
292
305
|
if json_data:
|
293
|
-
json_header = {"Content-Type": "application/json"}
|
306
|
+
json_header = {"Content-Type": "application/json; charset=utf-8"}
|
294
307
|
_LOGGER.debug("Adding %s to headers", json_header)
|
295
308
|
headers.update(json_header)
|
296
309
|
|
@@ -314,6 +327,16 @@ class AmazonEchoApi:
|
|
314
327
|
content_type,
|
315
328
|
)
|
316
329
|
|
330
|
+
if resp.status != HTTPStatus.OK:
|
331
|
+
if resp.status in [
|
332
|
+
HTTPStatus.FORBIDDEN,
|
333
|
+
HTTPStatus.PROXY_AUTHENTICATION_REQUIRED,
|
334
|
+
HTTPStatus.UNAUTHORIZED,
|
335
|
+
]:
|
336
|
+
raise CannotAuthenticate
|
337
|
+
if not self._ignore_ap_sigin_error(resp):
|
338
|
+
raise RequestFailed
|
339
|
+
|
317
340
|
await self._save_to_file(
|
318
341
|
await resp.text(),
|
319
342
|
url,
|
aioamazondevices/const.py
CHANGED
@@ -20,7 +20,6 @@ DOMAIN_BY_ISO3166_COUNTRY = {
|
|
20
20
|
},
|
21
21
|
"jp": {
|
22
22
|
"domain": "co.jp",
|
23
|
-
"openid.assoc_handle": "jpflex",
|
24
23
|
},
|
25
24
|
"br": {
|
26
25
|
"domain": "com.br",
|
@@ -41,8 +40,9 @@ DEFAULT_HEADERS = {
|
|
41
40
|
f"Mozilla/5.0 (iPhone; CPU iPhone OS {AMAZON_CLIENT_OS.replace('.', '_')} like Mac OS X) " # noqa: E501
|
42
41
|
"AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148"
|
43
42
|
),
|
44
|
-
"Accept-
|
43
|
+
"Accept-Charset": "utf-8",
|
45
44
|
"Accept-Encoding": "gzip",
|
45
|
+
"Accept-Language": "en-US",
|
46
46
|
"Connection": "keep-alive",
|
47
47
|
}
|
48
48
|
CSRF_COOKIE = "csrf"
|
aioamazondevices/exceptions.py
CHANGED
@@ -23,6 +23,10 @@ class CannotRegisterDevice(AmazonError):
|
|
23
23
|
"""Exception raised when device registration fails."""
|
24
24
|
|
25
25
|
|
26
|
+
class RequestFailed(AmazonError):
|
27
|
+
"""Exception raised when a request fails."""
|
28
|
+
|
29
|
+
|
26
30
|
class WrongMethod(AmazonError):
|
27
31
|
"""Exception raised when the wrong login metho is used."""
|
28
32
|
|
@@ -0,0 +1,10 @@
|
|
1
|
+
aioamazondevices/__init__.py,sha256=NpllEuw05uesvM4TISUrKdxZuuR9lLUDaTbRGceXAl8,276
|
2
|
+
aioamazondevices/api.py,sha256=kHupOo_Bu9dNLWiXHdJQuHJR47G8olJbn5ukZkSFV6Q,30715
|
3
|
+
aioamazondevices/const.py,sha256=C6__PALMP3bOn8350uA1jYDShKDkifD6GDn7A9Hlw7Q,4769
|
4
|
+
aioamazondevices/exceptions.py,sha256=nPbR928NryTbnxm5QwQpCSpRItvZ3PRYKynUUxH-_v4,1345
|
5
|
+
aioamazondevices/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
6
|
+
aioamazondevices/sounds.py,sha256=01pVCDFIuhrLypXInw4JNuHsC6zjMLsuKocet1R6we8,13409
|
7
|
+
aioamazondevices-3.0.9.dist-info/LICENSE,sha256=sS48k5sp9bFV-NSHDfAJuTZZ_-AP9ZDqUzQ9sffGlsg,11346
|
8
|
+
aioamazondevices-3.0.9.dist-info/METADATA,sha256=GrY-IiPzpkN3IjSX5Oyi8wj1dyUVzRtLZl4YCaNB5ZI,5546
|
9
|
+
aioamazondevices-3.0.9.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
|
10
|
+
aioamazondevices-3.0.9.dist-info/RECORD,,
|
@@ -1,10 +0,0 @@
|
|
1
|
-
aioamazondevices/__init__.py,sha256=u6ZFP_ZsxEPo8O698AoYIIiVYQpoUmBWvPu1foQZ8Wg,276
|
2
|
-
aioamazondevices/api.py,sha256=pMpW51Wu4G56uVhT29O7C-hoHgHYiNbP-7Lz9UCXz0E,29943
|
3
|
-
aioamazondevices/const.py,sha256=AHDQAcP7TIdGmAX-4m5OalyU-chiU6Eo3Ww2Hth15tE,4779
|
4
|
-
aioamazondevices/exceptions.py,sha256=qK_Hak9pc-lC2FPW-0i4rYIwNpEOHMmA9Rii8F2lkQo,1260
|
5
|
-
aioamazondevices/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
6
|
-
aioamazondevices/sounds.py,sha256=01pVCDFIuhrLypXInw4JNuHsC6zjMLsuKocet1R6we8,13409
|
7
|
-
aioamazondevices-3.0.7.dist-info/LICENSE,sha256=sS48k5sp9bFV-NSHDfAJuTZZ_-AP9ZDqUzQ9sffGlsg,11346
|
8
|
-
aioamazondevices-3.0.7.dist-info/METADATA,sha256=J6q7WBrgwQPBsX5bcDW-yfkQcshEvBy_3rf9SinFjxM,5546
|
9
|
-
aioamazondevices-3.0.7.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
|
10
|
-
aioamazondevices-3.0.7.dist-info/RECORD,,
|
File without changes
|
File without changes
|