pytolino 1.1__tar.gz → 1.2__tar.gz
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-1.1/src/pytolino.egg-info → pytolino-1.2}/PKG-INFO +3 -1
- {pytolino-1.1 → pytolino-1.2}/README.rst +2 -0
- {pytolino-1.1 → pytolino-1.2}/pyproject.toml +1 -1
- {pytolino-1.1 → pytolino-1.2}/src/pytolino/tolino_cloud.py +45 -0
- {pytolino-1.1 → pytolino-1.2/src/pytolino.egg-info}/PKG-INFO +3 -1
- {pytolino-1.1 → pytolino-1.2}/tests/test_tolino_cloud.py +27 -3
- {pytolino-1.1 → pytolino-1.2}/LICENSE +0 -0
- {pytolino-1.1 → pytolino-1.2}/MANIFEST.in +0 -0
- {pytolino-1.1 → pytolino-1.2}/setup.cfg +0 -0
- {pytolino-1.1 → pytolino-1.2}/src/pytolino/__init__.py +0 -0
- {pytolino-1.1 → pytolino-1.2}/src/pytolino/servers_settings.ini +0 -0
- {pytolino-1.1 → pytolino-1.2}/src/pytolino.egg-info/SOURCES.txt +0 -0
- {pytolino-1.1 → pytolino-1.2}/src/pytolino.egg-info/dependency_links.txt +0 -0
- {pytolino-1.1 → pytolino-1.2}/src/pytolino.egg-info/requires.txt +0 -0
- {pytolino-1.1 → pytolino-1.2}/src/pytolino.egg-info/top_level.txt +0 -0
|
@@ -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
|
|
@@ -63,6 +63,7 @@ You can then upload, add to a collection or delete ebook on your cloud:
|
|
|
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
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
|
|
66
67
|
client.logout()
|
|
67
68
|
|
|
68
69
|
|
|
@@ -87,6 +88,7 @@ Features
|
|
|
87
88
|
* delete ebook from the cloud
|
|
88
89
|
* add a book to a collection
|
|
89
90
|
* download inventory
|
|
91
|
+
* upload metadata
|
|
90
92
|
* more to come...
|
|
91
93
|
|
|
92
94
|
|
|
@@ -37,6 +37,7 @@ You can then upload, add to a collection or delete ebook on your cloud:
|
|
|
37
37
|
client.add_collection(epub_id, 'science fiction') # add the previous book to the collection science-fiction
|
|
38
38
|
client.delete_ebook(epub_id) # delete the previousely uploaded ebook
|
|
39
39
|
inventory = client.get_inventory() # get a list of all the books on the cloud and their metadata
|
|
40
|
+
client.upload_metadata(epub_id, title='my title', author='someone') # you can upload various kind of metadata
|
|
40
41
|
client.logout()
|
|
41
42
|
|
|
42
43
|
|
|
@@ -61,6 +62,7 @@ Features
|
|
|
61
62
|
* delete ebook from the cloud
|
|
62
63
|
* add a book to a collection
|
|
63
64
|
* download inventory
|
|
65
|
+
* upload metadata
|
|
64
66
|
* more to come...
|
|
65
67
|
|
|
66
68
|
|
|
@@ -364,6 +364,51 @@ class Client(object):
|
|
|
364
364
|
if host_response.status_code != 200:
|
|
365
365
|
raise PytolinoException('add to collection failed')
|
|
366
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
|
+
|
|
367
412
|
def upload(self, file_path, name=None, extension=None):
|
|
368
413
|
"""upload an ebook to your cloud
|
|
369
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
|
|
@@ -63,6 +63,7 @@ You can then upload, add to a collection or delete ebook on your cloud:
|
|
|
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
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
|
|
66
67
|
client.logout()
|
|
67
68
|
|
|
68
69
|
|
|
@@ -87,6 +88,7 @@ Features
|
|
|
87
88
|
* delete ebook from the cloud
|
|
88
89
|
* add a book to a collection
|
|
89
90
|
* download inventory
|
|
91
|
+
* upload metadata
|
|
90
92
|
* more to come...
|
|
91
93
|
|
|
92
94
|
|
|
@@ -168,8 +168,10 @@ def inventory_test():
|
|
|
168
168
|
inventory = client.get_inventory()
|
|
169
169
|
client.logout()
|
|
170
170
|
print(inventory[0].keys())
|
|
171
|
-
|
|
172
|
-
|
|
171
|
+
for item in inventory:
|
|
172
|
+
metadata = item['epubMetaData']
|
|
173
|
+
print(metadata.keys())
|
|
174
|
+
|
|
173
175
|
|
|
174
176
|
def delete_test():
|
|
175
177
|
|
|
@@ -181,5 +183,27 @@ def delete_test():
|
|
|
181
183
|
client.login(username, password)
|
|
182
184
|
client.delete_ebook(epub_id)
|
|
183
185
|
client.logout()
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
def metadata_test():
|
|
189
|
+
new_metadata = dict(publisher='someone')
|
|
190
|
+
with open(EPUB_ID_PATH, 'r') as myfile:
|
|
191
|
+
epub_id = myfile.read()
|
|
192
|
+
|
|
193
|
+
username, password = get_credentials()
|
|
194
|
+
client = Client()
|
|
195
|
+
client.login(username, password)
|
|
196
|
+
client.upload_metadata(epub_id, **new_metadata)
|
|
197
|
+
inventory = client.get_inventory()
|
|
198
|
+
for item in inventory:
|
|
199
|
+
item_metadata = item['epubMetaData']
|
|
200
|
+
if item_metadata['identifier'] == epub_id:
|
|
201
|
+
for key, value in new_metadata.items():
|
|
202
|
+
print(item_metadata[key])
|
|
203
|
+
client.logout()
|
|
204
|
+
|
|
205
|
+
|
|
184
206
|
if __name__ == '__main__':
|
|
185
|
-
|
|
207
|
+
# upload_test()
|
|
208
|
+
metadata_test()
|
|
209
|
+
# inventory_test()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|