mirror of
https://github.com/yihong0618/Kindle_download_helper.git
synced 2025-11-22 07:59:04 +08:00
fix: origins maybe a list? WTF
Signed-off-by: yihong0618 <zouzou0208@gmail.com>
This commit is contained in:
@@ -175,11 +175,7 @@ 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.get("origins", {}).get("origin", {}).get("type", "") == "Purchase"
|
||||
]
|
||||
ebooks = [e for e in ebooks if self._is_ebook(e)]
|
||||
pdocs = [i for i in library["meta_data"] if i["cde_contenttype"] == "PDOC"]
|
||||
unknow_index = 1
|
||||
|
||||
@@ -228,6 +224,15 @@ class NoKindle:
|
||||
self.ebooks = ebooks
|
||||
self.pdocs = pdocs
|
||||
|
||||
@staticmethod
|
||||
def _is_ebook(book_info):
|
||||
# https://github.com/yihong0618/Kindle_download_helper/issues/149#issuecomment-1805966855
|
||||
if not isinstance(book_info.get("origins"), dict):
|
||||
return False
|
||||
return (
|
||||
book_info.get("origins", {}).get("origin", {}).get("type", "") == "Purchase"
|
||||
)
|
||||
|
||||
def sidecar_ebook(self, asin):
|
||||
url = f"https://sars.amazon.com/sidecar/sa/EBOK/{asin}"
|
||||
r = self.session.send(
|
||||
|
||||
Reference in New Issue
Block a user