pytolino 1.2__py3-none-any.whl → 1.5__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/servers_settings.ini +0 -1
- pytolino/tolino_cloud.py +40 -1
- {pytolino-1.2.dist-info → pytolino-1.5.dist-info}/METADATA +25 -8
- pytolino-1.5.dist-info/RECORD +8 -0
- {pytolino-1.2.dist-info → pytolino-1.5.dist-info}/WHEEL +1 -1
- pytolino-1.2.dist-info/RECORD +0 -8
- {pytolino-1.2.dist-info → pytolino-1.5.dist-info}/LICENSE +0 -0
- {pytolino-1.2.dist-info → pytolino-1.5.dist-info}/top_level.txt +0 -0
pytolino/servers_settings.ini
CHANGED
|
@@ -26,5 +26,4 @@ sync_data_url = https://bosh.pageplace.de/bosh/rest/sync-data?paths=publicati
|
|
|
26
26
|
delete_url = https://bosh.pageplace.de/bosh/rest/deletecontent
|
|
27
27
|
inventory_url = https://bosh.pageplace.de/bosh/rest/inventory/delta
|
|
28
28
|
downloadinfo_url = https://bosh.pageplace.de/bosh/rest//cloud/downloadinfo/{}/{}/type/external-download
|
|
29
|
-
[www.buecher.de.extra]
|
|
30
29
|
form_send = 1
|
pytolino/tolino_cloud.py
CHANGED
|
@@ -26,6 +26,8 @@ SERVERS_SETTINGS_FILE_PATH = os.path.join(
|
|
|
26
26
|
servers_settings = configparser.ConfigParser()
|
|
27
27
|
servers_settings.read(SERVERS_SETTINGS_FILE_PATH)
|
|
28
28
|
|
|
29
|
+
PARTNERS = servers_settings.sections()
|
|
30
|
+
|
|
29
31
|
|
|
30
32
|
def main():
|
|
31
33
|
print(SERVERS_SETTINGS_FILE_PATH)
|
|
@@ -113,7 +115,9 @@ class Client(object):
|
|
|
113
115
|
def __init__(self, server_name='www.buecher.de'):
|
|
114
116
|
|
|
115
117
|
if server_name not in servers_settings:
|
|
116
|
-
raise PytolinoException(
|
|
118
|
+
raise PytolinoException(
|
|
119
|
+
f'the partner {server_name} was not found.'
|
|
120
|
+
f'please choose one of the list: {PARTNERS}')
|
|
117
121
|
|
|
118
122
|
self.access_token = None
|
|
119
123
|
self.refresh_token = None
|
|
@@ -122,6 +126,7 @@ class Client(object):
|
|
|
122
126
|
self.server_settings = servers_settings[server_name]
|
|
123
127
|
self.session = requests.session()
|
|
124
128
|
self.browser = mechanize.Browser()
|
|
129
|
+
self.browser.set_handle_robots(False)
|
|
125
130
|
self.server_name = server_name
|
|
126
131
|
|
|
127
132
|
def login(self, username, password):
|
|
@@ -487,6 +492,40 @@ class Client(object):
|
|
|
487
492
|
raise PytolinoException(
|
|
488
493
|
f'delete {ebook_id} failed: reason unknown.')
|
|
489
494
|
|
|
495
|
+
def add_cover(self, book_id, filepath, file_ext=None):
|
|
496
|
+
"""upload a a cover to a book on the cloud
|
|
497
|
+
|
|
498
|
+
:book_id: id of the book on the serveer
|
|
499
|
+
:filepath: path to the cover file
|
|
500
|
+
:file_ext: png, jpg or jpeg. only necessary if the filepath has no extension
|
|
501
|
+
|
|
502
|
+
"""
|
|
503
|
+
|
|
504
|
+
if file_ext is None:
|
|
505
|
+
ext = filepath.split('.')[-1]
|
|
506
|
+
|
|
507
|
+
mime = {
|
|
508
|
+
'png': 'image/png',
|
|
509
|
+
'jpeg': 'image/jpeg',
|
|
510
|
+
'jpg': 'image/jpeg'
|
|
511
|
+
}.get(ext.lower(), 'application/jpeg')
|
|
512
|
+
|
|
513
|
+
host_response = self.session.post(
|
|
514
|
+
self.server_settings['cover_url'],
|
|
515
|
+
files = [('file', ('1092560016', open(filepath, 'rb'), mime))],
|
|
516
|
+
data = {'deliverableId': book_id},
|
|
517
|
+
headers={
|
|
518
|
+
't_auth_token': self.access_token,
|
|
519
|
+
'hardware_id': self.hardware_id,
|
|
520
|
+
'reseller_id': self.server_settings['partner_id'],
|
|
521
|
+
},
|
|
522
|
+
)
|
|
523
|
+
|
|
524
|
+
self._log_requests(host_response)
|
|
525
|
+
|
|
526
|
+
if host_response.status_code != 200:
|
|
527
|
+
raise PytolinoException('cover upload failed.')
|
|
528
|
+
|
|
490
529
|
|
|
491
530
|
if __name__ == '__main__':
|
|
492
531
|
main()
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: pytolino
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.5
|
|
4
4
|
Summary: client for tolino cloud
|
|
5
5
|
Author: Imam Usmani
|
|
6
6
|
Project-URL: Source Code, https://github.com/ImamAzim/pytolino
|
|
@@ -16,13 +16,13 @@ License-File: LICENSE
|
|
|
16
16
|
Requires-Dist: requests
|
|
17
17
|
Requires-Dist: mechanize
|
|
18
18
|
Provides-Extra: dev
|
|
19
|
-
Requires-Dist: pytest
|
|
20
|
-
Requires-Dist: flake8
|
|
21
|
-
Requires-Dist: ipython
|
|
22
|
-
Requires-Dist: sphinx
|
|
23
|
-
Requires-Dist: build
|
|
24
|
-
Requires-Dist: twine
|
|
25
|
-
Requires-Dist: sphinx-rtd-theme
|
|
19
|
+
Requires-Dist: pytest; extra == "dev"
|
|
20
|
+
Requires-Dist: flake8; extra == "dev"
|
|
21
|
+
Requires-Dist: ipython; extra == "dev"
|
|
22
|
+
Requires-Dist: sphinx; extra == "dev"
|
|
23
|
+
Requires-Dist: build; extra == "dev"
|
|
24
|
+
Requires-Dist: twine; extra == "dev"
|
|
25
|
+
Requires-Dist: sphinx-rtd-theme; extra == "dev"
|
|
26
26
|
|
|
27
27
|
pytolino
|
|
28
28
|
===================
|
|
@@ -61,6 +61,7 @@ You can then upload, add to a collection or delete ebook on your cloud:
|
|
|
61
61
|
client.login(USERNAME, PASSWORD)
|
|
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
|
+
client.add_cover(epub_id, cover_path) # to upload a cover on the book.
|
|
64
65
|
client.delete_ebook(epub_id) # delete the previousely uploaded ebook
|
|
65
66
|
inventory = client.get_inventory() # get a list of all the books on the cloud and their metadata
|
|
66
67
|
client.upload_metadata(epub_id, title='my title', author='someone') # you can upload various kind of metadata
|
|
@@ -77,6 +78,22 @@ if you want to unregister your computer:
|
|
|
77
78
|
client.register() # now you will not be able to upload books from this computer
|
|
78
79
|
client.logout()
|
|
79
80
|
|
|
81
|
+
By default, it will connect to 'www.buecher.de'. In principle you could change the partner with:
|
|
82
|
+
|
|
83
|
+
.. code-block:: python
|
|
84
|
+
|
|
85
|
+
client = Client(server_name='www.orelfuessli') # for example if you have an account at orel fuessli.
|
|
86
|
+
|
|
87
|
+
To get a list of the supported partners:
|
|
88
|
+
|
|
89
|
+
.. code-block:: python
|
|
90
|
+
|
|
91
|
+
from pytolino.tolino_cloud import PARTNERS
|
|
92
|
+
print(PARTNERS)
|
|
93
|
+
|
|
94
|
+
Unfortunately, the only supported partner now is 'www.buecher.de', because it has a different way of connection... So for now, the only solution is to create an account there and link it to your original account.
|
|
95
|
+
|
|
96
|
+
|
|
80
97
|
|
|
81
98
|
Features
|
|
82
99
|
========
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
pytolino/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
+
pytolino/servers_settings.ini,sha256=IDhstCWbLHaMj3qEOYcbDABaIUKHIz1jEBke3uSE8bI,1473
|
|
3
|
+
pytolino/tolino_cloud.py,sha256=w4GaNMAQekpK8R8raYXOhFQM0CCIkiQgQaw__EBBtEg,18760
|
|
4
|
+
pytolino-1.5.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
|
5
|
+
pytolino-1.5.dist-info/METADATA,sha256=ADcTUDv3I0Wb6ywYh-MGSBX99dyIb145LlRQ8wp7Ebk,3703
|
|
6
|
+
pytolino-1.5.dist-info/WHEEL,sha256=P9jw-gEje8ByB7_hXoICnHtVCrEwMQh-630tKvQWehc,91
|
|
7
|
+
pytolino-1.5.dist-info/top_level.txt,sha256=3stGCqihEMMqlWGkME45OTJ0Prg-FO_kl554rtYNeuU,9
|
|
8
|
+
pytolino-1.5.dist-info/RECORD,,
|
pytolino-1.2.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=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,,
|
|
File without changes
|
|
File without changes
|