aioamazondevices 0.2.0__py3-none-any.whl → 0.4.0__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 +40 -11
- {aioamazondevices-0.2.0.dist-info → aioamazondevices-0.4.0.dist-info}/METADATA +1 -1
- aioamazondevices-0.4.0.dist-info/RECORD +9 -0
- aioamazondevices-0.2.0.dist-info/RECORD +0 -9
- {aioamazondevices-0.2.0.dist-info → aioamazondevices-0.4.0.dist-info}/LICENSE +0 -0
- {aioamazondevices-0.2.0.dist-info → aioamazondevices-0.4.0.dist-info}/WHEEL +0 -0
aioamazondevices/__init__.py
CHANGED
aioamazondevices/api.py
CHANGED
@@ -185,21 +185,43 @@ class AmazonEchoApi:
|
|
185
185
|
url,
|
186
186
|
data=input_data,
|
187
187
|
)
|
188
|
+
content_type = resp.headers.get("Content-Type", "")
|
189
|
+
_LOGGER.debug("Response content type: %s", content_type)
|
190
|
+
|
191
|
+
if "text/html" in content_type:
|
192
|
+
await self._save_to_file(
|
193
|
+
resp.text,
|
194
|
+
url,
|
195
|
+
)
|
196
|
+
elif content_type == "application/json":
|
197
|
+
await self._save_to_file(
|
198
|
+
orjson.dumps(
|
199
|
+
orjson.loads(resp.text),
|
200
|
+
option=orjson.OPT_INDENT_2,
|
201
|
+
).decode("utf-8"),
|
202
|
+
url,
|
203
|
+
extension="json",
|
204
|
+
)
|
188
205
|
|
189
|
-
await self._save_to_file(
|
190
|
-
resp.text,
|
191
|
-
url,
|
192
|
-
)
|
193
206
|
return BeautifulSoup(resp.content, "html.parser"), resp
|
194
207
|
|
195
|
-
async def _save_to_file(
|
196
|
-
|
208
|
+
async def _save_to_file(
|
209
|
+
self,
|
210
|
+
html_code: str,
|
211
|
+
url: str,
|
212
|
+
extension: str = "html",
|
213
|
+
output_path: str = "out",
|
214
|
+
) -> None:
|
215
|
+
"""Save response data to disk."""
|
197
216
|
if not self._save_html:
|
198
217
|
return
|
199
218
|
|
219
|
+
output_dir = Path(output_path)
|
220
|
+
output_dir.mkdir(parents=True, exist_ok=True)
|
221
|
+
|
200
222
|
url_split = url.split("/")
|
201
|
-
filename = f"{url_split[3]}-{url_split[4].split('?')[0]}.
|
202
|
-
with Path.open(
|
223
|
+
filename = f"{url_split[3]}-{url_split[4].split('?')[0]}.{extension}"
|
224
|
+
with Path.open(output_dir / filename, "w+") as file:
|
203
225
|
file.write(html_code)
|
204
226
|
file.write("\n")
|
205
227
|
|
@@ -275,12 +297,19 @@ class AmazonEchoApi:
|
|
275
297
|
"GET",
|
276
298
|
f"https://alexa.amazon.{self._domain}{URI_QUERIES[key]}",
|
277
299
|
)
|
300
|
+
_LOGGER.debug("Response URL: %s", raw_resp.url)
|
301
|
+
response_code = raw_resp.status_code
|
302
|
+
_LOGGER.debug("Response code: %s", response_code)
|
303
|
+
|
304
|
+
response_data = raw_resp.text
|
305
|
+
_LOGGER.debug("Response data: |%s|", response_data)
|
306
|
+
json_data = {} if len(raw_resp.content) == 0 else raw_resp.json()
|
307
|
+
|
308
|
+
_LOGGER.debug("JSON data: |%s|", json_data)
|
278
309
|
|
279
310
|
devices.update(
|
280
311
|
{
|
281
|
-
key:
|
282
|
-
raw_resp.text,
|
283
|
-
),
|
312
|
+
key: json_data,
|
284
313
|
},
|
285
314
|
)
|
286
315
|
|
@@ -0,0 +1,9 @@
|
|
1
|
+
aioamazondevices/__init__.py,sha256=DSS6phrrmu0Q8zWGTzUhabNcQr2KgMV-Gpc6TF9EkR0,276
|
2
|
+
aioamazondevices/api.py,sha256=XAUw079QI2CC6eL532_LVg566B-Nxo4WmO_IP2zL_P8,10789
|
3
|
+
aioamazondevices/const.py,sha256=bZaeO8AeJbDc5hdlbJ3cMwM9teTgYhExSR1oEpRFMLk,1089
|
4
|
+
aioamazondevices/exceptions.py,sha256=tERMur_gry9TmU3UyzndJO_CLViISn4b8ClrRbryFy8,444
|
5
|
+
aioamazondevices/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
6
|
+
aioamazondevices-0.4.0.dist-info/LICENSE,sha256=sS48k5sp9bFV-NSHDfAJuTZZ_-AP9ZDqUzQ9sffGlsg,11346
|
7
|
+
aioamazondevices-0.4.0.dist-info/METADATA,sha256=iN60iBJz_Zu6J3_fbheEZrWGmvJ5WgKv9dBU5TRgjl8,4680
|
8
|
+
aioamazondevices-0.4.0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
9
|
+
aioamazondevices-0.4.0.dist-info/RECORD,,
|
@@ -1,9 +0,0 @@
|
|
1
|
-
aioamazondevices/__init__.py,sha256=Zw6lQsQsOiDmSNnKKCTznWyMHgQ3us0XQsAww3w6YkU,276
|
2
|
-
aioamazondevices/api.py,sha256=0du0a0tWEtT-5sIHIfk8K5Zf0ntIBpYgY3nwER_Pcm4,9735
|
3
|
-
aioamazondevices/const.py,sha256=bZaeO8AeJbDc5hdlbJ3cMwM9teTgYhExSR1oEpRFMLk,1089
|
4
|
-
aioamazondevices/exceptions.py,sha256=tERMur_gry9TmU3UyzndJO_CLViISn4b8ClrRbryFy8,444
|
5
|
-
aioamazondevices/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
6
|
-
aioamazondevices-0.2.0.dist-info/LICENSE,sha256=sS48k5sp9bFV-NSHDfAJuTZZ_-AP9ZDqUzQ9sffGlsg,11346
|
7
|
-
aioamazondevices-0.2.0.dist-info/METADATA,sha256=ypYsMxLoVYrWxQdLA8cHM0-ysCPWVzIN3yxYxMLs_M8,4680
|
8
|
-
aioamazondevices-0.2.0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
9
|
-
aioamazondevices-0.2.0.dist-info/RECORD,,
|
File without changes
|
File without changes
|