polyglot.kindle module

Send documents or webpage articles to a kindle device or app

Author:David Young
Date Created:October 10, 2016
class polyglot.kindle.kindle(log, settings, urlOrPath, title=False, header=False, footer=False)[source]

Bases: polyglot.ebook.ebook

Send documents or webpage articles to a kindle device or app

Key Arguments:
  • log – logger
  • settings – the settings dictionary
  • urlOrPath – the url or path to the content source
  • title – the title of the output document. I. False then use the title of the original source. Default False
  • header – content to add before the article/book content in the resulting ebook. Default False
  • footer – content to add at the end of the article/book content in the resulting ebook. Default False

Usage:

To send content from a webpage article straight to your kindle device or smart phone app, you will first need to populate the email settings with polyglot’s settings file at ~.config/polyglot/polyglot.yaml, then use the following code:

from polyglot import kindle
sender = kindle(
    log=log,
    settings=settings,
    urlOrPath="http://www.thespacedoctor.co.uk/blog/2016/09/26/mysqlSucker-index.html",
    header='<a href="http://www.thespacedoctor.co.uk">thespacedoctor</a>',
    footer='<a href="http://www.thespacedoctor.co.uk">thespacedoctor</a>'
)
success = sender.send()

Success is True or False depending on the success/failure of sending the email to the kindle email address(es).

get_attachment(file_path)[source]

Get file as MIMEBase message

send()[source]

send the mobi book generated to kindle email address(es)

Return:
  • success – True or False depending on the success/failure of sending the email to the kindle email address(es).