Skip to content

BrenoAV/articles-to-kindle

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

News/Articles to Kindle

Introduction

Repository to store an application using Python to web scrapping news/articles from sites, transform in an epub format and send via email to a Kindle for reading.

mobile phone with news application opened Source: Photo by Obi - @pixel7propix on Unsplash


Setup

Clone this repository

Firstly, we need to clone this repository

$ git clone https://github.com/BrenoAV/articles-to-kindle.git && cd news-to-kindle/

Credentials (authenticate required)

  1. Go to https://console.cloud.google.com/apis/dashboard and create a new project

New project window

  1. Now, we need to enable the Google Gmail API. Search for Gmail API and turn on

Enable Gmail API window

  1. After to enable, we can create now our credentials using Oauth 2.0. For that, click on CredentialsCreate CredentialsOAuth client ID

Create credentials window

  • To create an OAuth client ID, you must first configure your consent screen. Click on create, select external, fill the mandatory forms: App Name, User support email, and Developer contact information
  1. Return to the Credentials tab and create now the OAuth client ID, and select Desktop application.

OAuth client ID select application type

Type a name for your OAuth client and click on create button.

  1. Click on download json and save it with the name credentials.json

Download json credentials window

Kindle email and .env file

# .env file
OUR_EMAIL = "youremail@gmail.com"
KINDLE_EMAIL = "yourkindleemail@kindle.com"

Dependencies

  • We need to install python's necessary dependencies:
$ pip install google-api-python-client google-auth-httplib2 google-auth-oauthlib pypandoc beautifulsoup4 PyYAML python-dotenv
  • We need to have pandoc installed in our system. This is a tutorial if you don't have yet: https://pandoc.org/installing.html

  • I ran this in a python environment using Debian Testing and python==3.11.2

Running the script

  1. After all the setup part you can now run: $ python main.py and will open the GUI of the program

Graphical Interface of the program

  1. Type link of the articles that you want to send for you kindle from https://www.bbc.com/future/ . I'll take this article here: https://www.bbc.com/future/article/20230405-why-ai-is-becoming-impossible-for-humans-to-understand

  2. Click on the button Send article to Kindle, and it'll prompt a window on your browser to authenticate. Click on the button Continue

Authenticate process window

  • This process when succeeded returns a response in the browser with the following text: "The authentication flow has completed. You may close this window."
  1. You'll receive the article in epub format in your Kindle. For me:

Result of the script, showing kindle article and web article side by side

TODO

  • Document the code (functions)
  • Add others sources of obtain news or articles
  • Improve the GUI with some errors if you put some invalid option or if the authenticate process fails
  • Add in the GUI to insert the emails instead of create a .env file