Metadata-Version: 2.4
Name: stkclient
Version: 0.2.0
Summary: Send To Kindle
License-Expression: MIT
License-File: LICENSE.rst
Author: Max Johnson
Author-email: maxdjohnson@gmail.com
Requires-Python: >=3.11,<4.0
Classifier: Development Status :: 4 - Beta
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Programming Language :: Python :: 3.15
Requires-Dist: defusedxml (>=0.7.1,<0.8.0)
Requires-Dist: rsa (>=4.9.1,<5.0.0)
Project-URL: Changelog, https://github.com/maxdjohnson/stkclient/releases
Project-URL: Documentation, https://stkclient.readthedocs.io
Project-URL: Homepage, https://github.com/maxdjohnson/stkclient
Project-URL: Repository, https://github.com/maxdjohnson/stkclient
Description-Content-Type: text/x-rst

Send To Kindle
==============

.. badges-start

|PyPI| |Status| |Python Version| |License|

|Read the Docs| |Tests| |Codecov|

.. |PyPI| image:: https://img.shields.io/pypi/v/stkclient.svg
   :target: https://pypi.org/project/stkclient/
   :alt: PyPI
.. |Status| image:: https://img.shields.io/pypi/status/stkclient.svg
   :target: https://pypi.org/project/stkclient/
   :alt: Status
.. |Python Version| image:: https://img.shields.io/pypi/pyversions/stkclient
   :target: https://pypi.org/project/stkclient
   :alt: Python Version
.. |License| image:: https://img.shields.io/pypi/l/stkclient
   :target: https://opensource.org/licenses/MIT
   :alt: License
.. |Read the Docs| image:: https://img.shields.io/readthedocs/stkclient/latest.svg?label=Read%20the%20Docs
   :target: https://stkclient.readthedocs.io/
   :alt: Read the documentation at https://stkclient.readthedocs.io/
.. |Tests| image:: https://github.com/maxdjohnson/stkclient/workflows/Tests/badge.svg
   :target: https://github.com/maxdjohnson/stkclient/actions?workflow=Tests
   :alt: Tests
.. |Codecov| image:: https://codecov.io/gh/maxdjohnson/stkclient/branch/main/graph/badge.svg
   :target: https://codecov.io/gh/maxdjohnson/stkclient
   :alt: Codecov

.. badges-end


``stkclient`` implements a client for amazon's "Send to Kindle" service. It allows python programs to
send files to a kindle device without the 10mb limit that applies to email files.

Features
--------

* OAuth-based authorization
* Send large (>10MB) files to Kindle devices


Installation
------------

Python 3.11 or later is required. You can install *Send To Kindle* via pip_ from PyPI_:

.. code:: console

   $ pip install stkclient


Creating a Client
-----------------

To create a client, you must authenticate the user. Currently the only supported authentication mechanism is OAuth2:

.. code:: python

   import stkclient

   a = stkclient.OAuth2()
   signin_url = a.get_signin_url()
   # Open `signin_url` in a browser, sign in and authorize the application, pass
   # the final redirect_url below
   client = a.create_client(redirect_url)

Once a client is created, it can be serialized and deserialized using ``Client.load`` / ``Client.loads`` and ``client.dump`` / ``client.dumps``

.. code:: python

   with open('client.json', 'w') as f:
       client.dump(f)
   with open('client.json', 'r') as f:
       client = stkclient.Client.load(f)


Sending a File
--------------

Once you have a Client object, you can list devices and send files to specified devices.

.. code:: python

   devices = client.get_owned_devices()
   destinations = [d.device_serial_number for d in devices]
   client.send_file(filepath, destinations, author=author, title=title, format="epub")

The ``format`` argument describes the input file. PDFs are delivered with their
original page layout by default. To convert a PDF to Kindle format, set
``force_convert=True``:

.. code:: python

   client.send_file(
       filepath, destinations, author=author, title=title,
       format="pdf", force_convert=True,
   )


Development
-----------

Install the CI tools with Python 3.12, then run the same Nox sessions as CI:

.. code:: console

   $ python3.12 -m pip install -c .github/workflows/constraints.txt poetry poetry-plugin-export nox nox-poetry
   $ nox -s tests-3.12 mypy typeguard xdoctest docs-build pre-commit audit

CI tests Python 3.11 through 3.15 and runs the newest version on Linux, macOS,
and Windows. The minimum Python version follows the `Python support schedule`_.
Maintenance tools run on Python 3.12. The ``audit`` session checks locked runtime,
test, and development dependencies against the PyPI vulnerability database.
The documentation build treats warnings as errors. Pull requests also build the
release distributions; publishing remains limited to pushes to the main branch.

.. _Python support schedule: https://devguide.python.org/versions/


Related Projects
----------------

`KindBeamer <https://github.com/jooray/kindbeamer>`__ a GUI application implementing the same protocol.


License
-------

Distributed under the terms of the `MIT license`_,
*Send To Kindle* is free and open source software.


Credits
-------

Project structure from `@cjolowicz`_'s `Hypermodern Python Cookiecutter`_ template.

.. _@cjolowicz: https://github.com/cjolowicz
.. _MIT license: https://opensource.org/licenses/MIT
.. _PyPI: https://pypi.org/
.. _Hypermodern Python Cookiecutter: https://github.com/cjolowicz/cookiecutter-hypermodern-python
.. _pip: https://pip.pypa.io/

