File tree Expand file tree Collapse file tree 2 files changed +18
-4
lines changed Expand file tree Collapse file tree 2 files changed +18
-4
lines changed Original file line number Diff line number Diff line change @@ -51,7 +51,8 @@ def read_from_file(key):
51
51
'Pillow' ,
52
52
'pyaes' ,
53
53
'rsa' ,
54
- 'xmltodict'
54
+ 'xmltodict' ,
55
+ 'amazon.ion'
55
56
],
56
57
extras_require = {
57
58
'docs' : [
Original file line number Diff line number Diff line change 1
1
# found api endpoints
2
- # have to find out more
3
-
2
+ # there are many more but what they do?
4
3
4
+ import base64
5
5
import json
6
6
from datetime import datetime
7
7
8
8
import httpx
9
9
import xmltodict
10
+ from amazon .ion import simpleion
10
11
11
12
12
13
def get_library (auth ):
@@ -27,6 +28,12 @@ def _build_correlation_id(auth, asin):
27
28
return f"Device:{ device } :{ serial } ;kindle.EBOK:{ asin } :{ timestamp } "
28
29
29
30
31
+ def _b64ion_to_dict (b64ion : str ):
32
+ ion = base64 .b64decode (b64ion )
33
+ ion = simpleion .loads (ion )
34
+ return dict (ion )
35
+
36
+
30
37
def get_manifest (auth , asin : str ):
31
38
asin = asin .upper ()
32
39
url = f"https://kindle-digital-delivery.amazon.com/delivery/manifest/kindle.ebook/{ asin } "
@@ -42,7 +49,13 @@ def get_manifest(auth, asin: str):
42
49
}
43
50
with httpx .Client (auth = auth ) as session :
44
51
r = session .get (url , headers = headers )
45
- return r .json ()
52
+ manifest = r .json ()
53
+
54
+ manifest ["responseContext" ] = _b64ion_to_dict (manifest ["responseContext" ])
55
+ for resource in manifest ["resources" ]:
56
+ if resource .get ("responseContext" ):
57
+ resource ["responseContext" ] = _b64ion_to_dict (resource ["responseContext" ])
58
+ return manifest
46
59
47
60
48
61
def whispersync (auth ):
You can’t perform that action at this time.
0 commit comments