Skip to main content

client for tolino cloud

Project description

UPDATE

because of heavy anti-bot protection, it is no longer possible to make a fully automatic login. One can however reuse authorization token after a manual login. The token can then be refreshed automatically, for example with a cronjob (at least once per hour.)

pytolino

A client to interact (login, upload, delete ebooks, etc..) with the tolino cloud with python. thanks to https://github.com/darkphoenix/tolino-calibre-sync for the inspiration.

One difference is that I aim to create a python package from it and to put it on pypi, so that one can use this python module in other projects.

Installation

pip install pytolino

Usage

First, login manually, and use an inspector tool in the browser to inspect the requests. After connecting to the digital libray of tolino, there is POST request (named token). From the request response, copy the value of the refresh token (and the expiration time in seconds). Then, in a PATH request, in the request header, find the device_id number.

You can then store the token:

from pytolino.tolino_cloud import Client
partner = 'orellfuessli'
account_name = 'any name for reference'
client = Client(partner)
print('login on your browser and get the token.')
refresh_token = input('refresh token:\n')
expires_in = int(input('expires_in:\n'))
hardware_id = input('hardware id:\n')
Client.store_token(
account_name, refresh_token, expires_in, hardware_id)

Then, get a new access token. It will expires in 1 hours, so you might want to create a crontab job to do it regularely:

from pytolino.tolino_cloud import Client
partner = 'orellfuessli'
account_name = 'any name for reference'
client = Client(partner)
client.get_new_token(account_name)

After this, instead of login, you only need to retrieve the access token that is stored on disk and upload, delete books, etc…

from pytolino.tolino_cloud import Client
partner = 'orellfuessli'
account_name = 'any name for reference'
client = Client(partner)
client.retrieve_token(account_name)

ebook_id = client.upload(EPUB_FILE_PATH) # return a unique id that can be used for reference
client.add_collection(epub_id, 'science fiction') # add the previous book to the collection science-fiction
client.add_cover(epub_id, cover_path) # to upload a cover on the book.
client.delete_ebook(epub_id) # delete the previousely uploaded ebook
inventory = client.get_inventory() # get a list of all the books on the cloud and their metadata
client.upload_metadata(epub_id, title='my title', author='someone') # you can upload various kind of metadata

To get a list of the supported partners:

from pytolino.tolino_cloud import PARTNERS
print(PARTNERS)

for now, only orelfuessli is supported, but it should be easy to include the others (but always need of a manual login)

Features

  • upload ebook

  • delete ebook from the cloud

  • add a book to a collection

  • download inventory

  • upload metadata

License

The project is licensed under GNU GENERAL PUBLIC LICENSE v3.0

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytolino-2.2.tar.gz (20.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pytolino-2.2-py3-none-any.whl (18.9 kB view details)

Uploaded Python 3

File details

Details for the file pytolino-2.2.tar.gz.

File metadata

  • Download URL: pytolino-2.2.tar.gz
  • Upload date:
  • Size: 20.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for pytolino-2.2.tar.gz
Algorithm Hash digest
SHA256 6134f6913b5894da94e148c54e7733827baf59d1b5a017fc826ea792a72a0315
MD5 e8d3c0165bcf9d705a3fe46c57fbf847
BLAKE2b-256 6af54fb815b8f602c9dfb2efb41b219087dd7d2e99980e523c6a4d330e612e15

See more details on using hashes here.

File details

Details for the file pytolino-2.2-py3-none-any.whl.

File metadata

  • Download URL: pytolino-2.2-py3-none-any.whl
  • Upload date:
  • Size: 18.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for pytolino-2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 4484700ad16b8ce0bcbdedc12858c43435614dde189501882476bec01bd5abbd
MD5 16ab711d0d63c50bba159fbe7c5b6c99
BLAKE2b-256 1f0045ae63870d4d326a566ee0a7dbd716c28692a9804317f0b8e7ce5361db5f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page