Skip to main content

client for tolino cloud

Project description

UPDATE

because of heavy anti-bot protection, it is more difficult to make a fully automatic login on a headless device. If one is not on a headless device, it will login using seleniubbase, but you might have to install chromium browser. On a headless device, one needs to install xvfb to simulate a non-headless device. Alternatively, on can import manually a refresh token. It can be used to get a new access token, (for example regulary witha cronjob), but it will eventually expire after 10 hours.

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, one need to login. if chromium browser is installed and there is a monitor, it can be done automaticaly:

from pytolino.tolino_cloud import Client
partner = 'orellfuessli'
client = Client(partner=partner,username='USERNAME)
client.login('PASSWORD')

if this is the first login on the device, it will use selenium and store an access token on the device.

On a headless device, this will work only if xvfb is installed.

Alternatively, one can instead import a refresh token: First, login manually with another device, 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. Then, in a PATCH request, in the request header, find the device_id number.

You can then import the token:

client = Client(username='USERNAME')
print('please login manually and use inspector tool to find refresh token'
      ' in a token request')
refresh_token = input('refresh login: ')
print('find the hardware id in the request header '
      'of a patch request for example')
hardware_id = input('hardware id: ')
client.import_token(refresh_token, hardware_id)
client.login('PASSWORD', allow_GUI_autologin=False)  # seleniumbase will not be used

After this, the login will method will only refresh the access token for on hour, and you can work with the libraty:

try:
    client.login(password)
except PytolinoException as e:
    print(e)
else:
    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-3.2.tar.gz (3.0 MB view details)

Uploaded Source

Built Distribution

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

pytolino-3.2-py3-none-any.whl (24.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pytolino-3.2.tar.gz
  • Upload date:
  • Size: 3.0 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for pytolino-3.2.tar.gz
Algorithm Hash digest
SHA256 75110a7b09931b0b8f9a26b9980ba18d1772f5edd2d3deba6af8f15810cc8da4
MD5 b8bec2936cc7ef3b3e6e8def4c7cb9c2
BLAKE2b-256 429cd444993bd9ac74defcddeba79e73fba57bd3cf9862a13fa035070a9e5d26

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pytolino-3.2-py3-none-any.whl
  • Upload date:
  • Size: 24.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for pytolino-3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 928785a8a33c8414089980c0d28431b5e557232d1dc3bc804532019fbdf7ff24
MD5 78f91d7f9be2e86c83fd6822c62e434d
BLAKE2b-256 287fbc5499b8dfa42e3314012b9fabc524ab4a63a3edf3a6e4f102949c4412a9

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