trustmaster / gkeep2notion

Export contents from Google Keep and import it into Notion
Apache License 2.0
88 stars 16 forks source link
google-keep notion

Google Keep -> Notion

Exports notes and lists from Google Keep and imports them into your Notion.

Features

Supports exporting:

Installation

This script requires Python 3.9+, https://github.com/kiwiz/gkeepapi, https://github.com/ramnes/notion-sdk-py, and a couple more libraries to run. Install the pre-requisite libraries via Pip3:

pip3 install -r requirements.txt

Optional: make the script executable:

chmod +x gkeep2notion.py

Preventing "Authentication failed" on some systems


Running inside of a Docker Container

In order to use the gkeepapi dependency, you'll need to run it inside of a docker container that is compatible with it. Otherwise you'll most likely run into an "Authentication failed" error.

  1. Build the Docker Image
    docker build -t gkeep2notion_image .
  2. Run the Docker Container
    docker run -it --name gkeep2notion_container gkeep2notion_image /bin/bash
  3. Now you should be inside the container and the rest of the guide should work

On some systems the authentication fails even with valid credentials. This may happen because of three reasons:

  1. You have enabled 2FA on your account
  2. Google issues a CAPTCHA for your IP address
  3. SSL certificate validation fails.

To fix the 2FA problem:

You need to create an app specific password for the script.

  1. Go to https://myaccount.google.com/apppasswords
  2. Login to your account
  3. Under the Select the app and device you want to generate the app password for. section:
    1. Select Other(Custom name) from the Select app dropdown
    2. Enter some name like gkeep2notion and click on Generate button
    3. Copy password from the popup and click Done
  4. Use this copied password in your terminal when script prompts for password

To fix the CAPTCHA problem:

Try using the Unlock CAPTCHA link before retrying login.

**To try fixing the SSL problem:***

Revert to an older version of the following library:

pip3 install requests==2.23.0

Configuration

Before use, copy config.example.ini to config.ini and edit its contents. See configuration explanation below:

[gkeep]
email=your_name@gmail.com # Your Google account
import_notes=true # Set to false if you don't want to import notes
import_todos=true # Set to false if you don't want to import TODO lists
import_media=true # Set to false if you don't need to import images and audio

[notion]
token=Copy it from your Notion integratin # See documentation below
root_url=https://notion.so/PAGE-ID Create a root url in your Notion # See documentation below

Obtaining Notion token

The importer needs to access your Notion account and it needs to know the root URL in which to import all the Google Keep contents.

To get a Notion authentication token:

  1. Go to your Notion integrations
  2. Click "Create new integration"
  3. Enter any name, e.g. gkeep2notion. As per Integration type, choose Internal integration. In the Capabilities make sure this integration can Read, Update, and Insert content.
  4. After creating the integration copy the "Internal Integration Token" value to the token in your config.ini.

Configuring the root_url

This script imports all the content under a certain page in Notion that has to exist already. It is recommended to create a special page for the imported content, and then migrate it to your regular Notion structure from there.

  1. Create a new page in Notion e.g. "Google Keep import"
  2. Click on ••• button on top right of the page and select "Add Connections" (at the bottom) from the menu.
  3. Search for your integration name and select it. You should press "Confirm" on the dialog that will appear. This will make the page accessible to your integration.
  4. Copy the URL of the page in the address bar or use "Copy link" in the context menu of the navigation bar
  5. Paste that link to root_url in the config.ini.

Usage

Google authentication

The first time you run gkeep2notion it will ask for your Google Account's password to authenticate into your Google Keep account. After obtaining an authentication token, gkeep2notion saves it in your system's keyring. Next time you won't need to enter the password again.

Import everything

Note: export/import takes a considerable amount of time. Especially when working with notes containing media files. So you may want to try importing a subset of your records before importing everything.

By default gkeep2notion exports everything in your Google Keep account and imports it into Notion. It can be done as simple as:

./gkeep2notion.py

Google Keep search query

You can use the search function built into Google Keep to import notes matching a search query:

./gkeep2notion.py -q 'Orange apple'

Import specific labels

You can import notes and tasklists containing specific label(s) in Google Keep using the -l option.

An example with one label:

./gkeep2notion.py -l cooking

An example with multiple labels, comma separated:

./gkeep2notion.py -l 'work, business, management'

Credits

This tool uses the unofficial Google Keep API for Python by kiwiz. Google Keep is of course a registered trademark of Google and neither the API nor this script are affiliated with Google, Inc.

Thanks to ramnes for the unofficial Notion Python SDK. Neither that API nor this script are affiliated with Notion. Notion is a trademark of Notion Labs, Inc.