pytolino 1.0__py3-none-any.whl → 1.2__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.
- pytolino/tolino_cloud.py +85 -0
- {pytolino-1.0.dist-info → pytolino-1.2.dist-info}/METADATA +5 -1
- pytolino-1.2.dist-info/RECORD +8 -0
- pytolino-1.0.dist-info/RECORD +0 -8
- {pytolino-1.0.dist-info → pytolino-1.2.dist-info}/LICENSE +0 -0
- {pytolino-1.0.dist-info → pytolino-1.2.dist-info}/WHEEL +0 -0
- {pytolino-1.0.dist-info → pytolino-1.2.dist-info}/top_level.txt +0 -0
pytolino/tolino_cloud.py
CHANGED
|
@@ -288,6 +288,46 @@ class Client(object):
|
|
|
288
288
|
raise PytolinoException(
|
|
289
289
|
f'unregister {device_id} failed: reason unknown.')
|
|
290
290
|
|
|
291
|
+
def get_inventory(self):
|
|
292
|
+
"""download a list of the books on the cloud and their information
|
|
293
|
+
:returns: list of dict describing the book, with a epubMetaData dict
|
|
294
|
+
|
|
295
|
+
"""
|
|
296
|
+
|
|
297
|
+
host_response = self.session.get(
|
|
298
|
+
self.server_settings['inventory_url'],
|
|
299
|
+
params={'strip': 'true'},
|
|
300
|
+
headers={
|
|
301
|
+
't_auth_token': self.access_token,
|
|
302
|
+
'hardware_id': self.hardware_id,
|
|
303
|
+
'reseller_id': self.server_settings['partner_id'],
|
|
304
|
+
}
|
|
305
|
+
)
|
|
306
|
+
|
|
307
|
+
self._log_requests(host_response)
|
|
308
|
+
if host_response.status_code != 200:
|
|
309
|
+
raise PytolinoException('invetory request failed')
|
|
310
|
+
|
|
311
|
+
try:
|
|
312
|
+
j = host_response.json()
|
|
313
|
+
except requests.JSONDecodeError:
|
|
314
|
+
raise PytolinoException(
|
|
315
|
+
'inventory list request failed because of json error.'
|
|
316
|
+
)
|
|
317
|
+
else:
|
|
318
|
+
try:
|
|
319
|
+
publication_inventory = j['PublicationInventory']
|
|
320
|
+
uploaded_ebooks = publication_inventory['edata']
|
|
321
|
+
purchased_ebook = publication_inventory['ebook']
|
|
322
|
+
except KeyError:
|
|
323
|
+
raise PytolinoException(
|
|
324
|
+
'inventory list request failed because',
|
|
325
|
+
'of key error in json.',
|
|
326
|
+
)
|
|
327
|
+
else:
|
|
328
|
+
inventory = uploaded_ebooks + purchased_ebook
|
|
329
|
+
return inventory
|
|
330
|
+
|
|
291
331
|
def add_to_collection(self, book_id, collection_name):
|
|
292
332
|
"""add a book to a collection on the cloud
|
|
293
333
|
|
|
@@ -324,6 +364,51 @@ class Client(object):
|
|
|
324
364
|
if host_response.status_code != 200:
|
|
325
365
|
raise PytolinoException('add to collection failed')
|
|
326
366
|
|
|
367
|
+
def upload_metadata(self, book_id, **new_metadata):
|
|
368
|
+
"""upload some metadata to a specific book on the cloud
|
|
369
|
+
|
|
370
|
+
:book_id: ref on the cloud of the book
|
|
371
|
+
:**meta_data: dict of metadata than can be changed
|
|
372
|
+
|
|
373
|
+
"""
|
|
374
|
+
|
|
375
|
+
url = self.server_settings['meta_url'] + f'/?deliverableId={book_id}'
|
|
376
|
+
host_response = self.session.get(
|
|
377
|
+
url,
|
|
378
|
+
headers={
|
|
379
|
+
't_auth_token': self.access_token,
|
|
380
|
+
'hardware_id': self.hardware_id,
|
|
381
|
+
'reseller_id': self.server_settings['partner_id'],
|
|
382
|
+
}
|
|
383
|
+
)
|
|
384
|
+
|
|
385
|
+
book = host_response.json()
|
|
386
|
+
self._log_requests(host_response)
|
|
387
|
+
if host_response.status_code != 200:
|
|
388
|
+
raise PytolinoException('metadata upload failed')
|
|
389
|
+
|
|
390
|
+
for key, value in new_metadata.items():
|
|
391
|
+
book['metadata'][key] = value
|
|
392
|
+
|
|
393
|
+
payload = {
|
|
394
|
+
'uploadMetaData': book['metadata']
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
host_response = self.session.put(
|
|
398
|
+
url,
|
|
399
|
+
data=json.dumps(payload),
|
|
400
|
+
headers={
|
|
401
|
+
'content-type': 'application/json',
|
|
402
|
+
't_auth_token': self.access_token,
|
|
403
|
+
'hardware_id': self.hardware_id,
|
|
404
|
+
'reseller_id': self.server_settings['partner_id'],
|
|
405
|
+
}
|
|
406
|
+
)
|
|
407
|
+
|
|
408
|
+
self._log_requests(host_response)
|
|
409
|
+
if host_response.status_code != 200:
|
|
410
|
+
raise PytolinoException('metadata upload failed')
|
|
411
|
+
|
|
327
412
|
def upload(self, file_path, name=None, extension=None):
|
|
328
413
|
"""upload an ebook to your cloud
|
|
329
414
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: pytolino
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.2
|
|
4
4
|
Summary: client for tolino cloud
|
|
5
5
|
Author: Imam Usmani
|
|
6
6
|
Project-URL: Source Code, https://github.com/ImamAzim/pytolino
|
|
@@ -62,6 +62,8 @@ You can then upload, add to a collection or delete ebook on your cloud:
|
|
|
62
62
|
ebook_id = client.upload(EPUB_FILE_PATH) # return a unique id that can be used for reference
|
|
63
63
|
client.add_collection(epub_id, 'science fiction') # add the previous book to the collection science-fiction
|
|
64
64
|
client.delete_ebook(epub_id) # delete the previousely uploaded ebook
|
|
65
|
+
inventory = client.get_inventory() # get a list of all the books on the cloud and their metadata
|
|
66
|
+
client.upload_metadata(epub_id, title='my title', author='someone') # you can upload various kind of metadata
|
|
65
67
|
client.logout()
|
|
66
68
|
|
|
67
69
|
|
|
@@ -85,6 +87,8 @@ Features
|
|
|
85
87
|
* upload ebook
|
|
86
88
|
* delete ebook from the cloud
|
|
87
89
|
* add a book to a collection
|
|
90
|
+
* download inventory
|
|
91
|
+
* upload metadata
|
|
88
92
|
* more to come...
|
|
89
93
|
|
|
90
94
|
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
pytolino/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
+
pytolino/servers_settings.ini,sha256=F8wSIWwl4XhQJKrhhbHtLhpXtfaGI7ODoD-VReaseBQ,1496
|
|
3
|
+
pytolino/tolino_cloud.py,sha256=qZA35bHpfMjaHd97dcsl3uRqoL64ts8o6DJ-hWUGkPQ,17402
|
|
4
|
+
pytolino-1.2.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
|
5
|
+
pytolino-1.2.dist-info/METADATA,sha256=74bkCmM2y9gp6fWEINEB_3KHPB7cpAfwgyBLNBEsRR0,3061
|
|
6
|
+
pytolino-1.2.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
|
|
7
|
+
pytolino-1.2.dist-info/top_level.txt,sha256=3stGCqihEMMqlWGkME45OTJ0Prg-FO_kl554rtYNeuU,9
|
|
8
|
+
pytolino-1.2.dist-info/RECORD,,
|
pytolino-1.0.dist-info/RECORD
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
pytolino/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
-
pytolino/servers_settings.ini,sha256=F8wSIWwl4XhQJKrhhbHtLhpXtfaGI7ODoD-VReaseBQ,1496
|
|
3
|
-
pytolino/tolino_cloud.py,sha256=e1BMWHiF83scNm3pbByRSnCjVBZv4YNYuQBtkpmlpPY,14345
|
|
4
|
-
pytolino-1.0.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
|
5
|
-
pytolino-1.0.dist-info/METADATA,sha256=RRsrHj5-YAEAKO-1DxBkFP1bA-x7Z7dJqzG3d1ShOO4,2807
|
|
6
|
-
pytolino-1.0.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
|
|
7
|
-
pytolino-1.0.dist-info/top_level.txt,sha256=3stGCqihEMMqlWGkME45OTJ0Prg-FO_kl554rtYNeuU,9
|
|
8
|
-
pytolino-1.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|