mirror of
https://github.com/yihong0618/Kindle_download_helper.git
synced 2025-11-22 07:59:04 +08:00
fix: handle potential KeyError
When fetching a large number of personal documents, there is a chance of
receiving the following JSON structure leading to a KeyError:
```json
{"OwnershipData":{"success":false,"error":"GENERIC_ERROR"}}
```
In this case, ignore the error and continue execution.
This commit is contained in:
@@ -334,7 +334,11 @@ class Kindle:
|
||||
if not result.get("success", True):
|
||||
logger.error("get all books error: %s", result.get("error"))
|
||||
break
|
||||
items = result["OwnershipData"]["items"]
|
||||
try:
|
||||
items = result["OwnershipData"]["items"]
|
||||
except KeyError:
|
||||
logger.error("get all books error: %s", result.get("error"))
|
||||
break
|
||||
for item in items:
|
||||
if filetype == "PDOC":
|
||||
item["title"] = html.unescape(item["title"])
|
||||
|
||||
Reference in New Issue
Block a user