mirror of
https://github.com/yihong0618/Kindle_download_helper.git
synced 2025-11-22 07:59:04 +08:00
error: ebooks = [e for e in ebooks if e["origins"]["origin"]["type"] == "purchase"] TypeError: list indices must be integers or slices,not str Signed-off-by: yihong0618 <zouzou0208@gmail.com>
This commit is contained in:
@@ -183,6 +183,7 @@ def login(email, password, domain="com", device_id=DEVICE_ID):
|
||||
"device_os_family": "android",
|
||||
"device_type": DEVICE_TYPE,
|
||||
"device_serial": device_id,
|
||||
"mac_address": secrets.token_hex(64).upper(),
|
||||
"manufacturer": MANUFACTURER,
|
||||
"model": DEVICE_NAME,
|
||||
"os_version": "30",
|
||||
@@ -346,7 +347,6 @@ def register_device(tokens=None, is_com=False):
|
||||
parsed_response = xmltodict.parse(resp.text)
|
||||
tokens["device_private_key"] = parsed_response["response"]["device_private_key"]
|
||||
tokens["adp_token"] = parsed_response["response"]["adp_token"]
|
||||
|
||||
save_tokens(tokens, is_com=is_com)
|
||||
return tokens
|
||||
|
||||
|
||||
@@ -522,7 +522,9 @@ class Kindle:
|
||||
pass
|
||||
except Exception as e:
|
||||
logger.error(str(e))
|
||||
logger.error(f"Index: {index + 1}, Title: {title}, Asin: {asin} download failed")
|
||||
logger.error(
|
||||
f"Index: {index + 1}, Title: {title}, Asin: {asin} download failed"
|
||||
)
|
||||
|
||||
def download_books(self, start_index=0, filetype="EBOK"):
|
||||
# use default device
|
||||
|
||||
@@ -175,10 +175,13 @@ class NoKindle:
|
||||
library = json.loads(json.dumps(library))
|
||||
library = library["response"]["add_update_list"]
|
||||
ebooks = [i for i in library["meta_data"] if i["cde_contenttype"] == "EBOK"]
|
||||
ebooks = [e for e in ebooks if e["origins"]["origin"]["type"] == "Purchase"]
|
||||
ebooks = [
|
||||
e
|
||||
for e in ebooks
|
||||
if e.get("origins", {}).get("origin", {}).get("type", "") == "Purchase"
|
||||
]
|
||||
pdocs = [i for i in library["meta_data"] if i["cde_contenttype"] == "PDOC"]
|
||||
unknow_index = 1
|
||||
# for i in pdocs + ebooks:
|
||||
|
||||
for i in ebooks + pdocs:
|
||||
if isinstance(i["title"], dict):
|
||||
@@ -514,7 +517,6 @@ class NoKindle:
|
||||
"X-ADP-AttemptCount": "1",
|
||||
"X-ADP-CorrelationId": correlation_id,
|
||||
"X-ADP-Transport": str(manifest["responseContext"]["transport"]),
|
||||
"X-ADP-Reason": str(manifest["responseContext"]["reason"]),
|
||||
"x-amzn-accept-type": "application/x.amzn.digital.deliverymanifest@1.0",
|
||||
"X-ADP-SW": str(manifest["responseContext"]["swVersion"]),
|
||||
"X-ADP-LTO": "60",
|
||||
@@ -629,7 +631,7 @@ class NoKindle:
|
||||
self._save_to_epub(out_dedrm, out_epub)
|
||||
|
||||
def download_all_ebooks(self):
|
||||
for b in self.ebooks:
|
||||
for b in self.ebooks[18:]:
|
||||
try:
|
||||
self.download_book(b["ASIN"])
|
||||
except Exception as e:
|
||||
|
||||
Reference in New Issue
Block a user