Giter VIP home page Giter VIP logo

kindle-to-notion's Introduction

🚀 Kindle to Notion

Seamlessly transfer your Kindle highlights to a Notion Database!

🔁 Usage

Before you can run the sync, you need to complete the setup section.

To sync your highlights, just upload the new My Clippings.txt file into your GitHub repo. It will trigger a GitHub Action to sync the newly added highlights to your Notion books database.

⚙️ Setup

  • Duplicate my Notion books database as a template in your Notion account. You don't need to clone the contents of my database. You only need to database table. This will serve as your Notion books database.

  • Create a new internal integration at https://www.notion.so/my-integrations and copy the Notion API key.

  • Go to your Notion dashboard. Open your books database as a page. Click on the three dots icon (more options) and go to Add connection. Search for the integration you created in the previous step and add it as a connection.

  • On the Notion books database page, go to Share and click on Copy link to get the URL of the Notion database.

  • Now, extract the Database Id from the link as shown in the example below:

    Book Database Link: https://www.notion.so/arkalim/346be84507ff482b80fceb4024deadc2?v=e868075eaf5749bc941e617e651295fb
    Book Database Id: 346be84507ff482b80fceb4024deadc2
    
  • Connect your Kindle E-Reader to your computer. Navigate to Kindledocuments and copy My Clippings.txt.

  • Create a GitHub repository and add your My Clippings.txt to the root of the repository. Now, add a file sync.yaml to the repository at location .github/workflows with the following content:

    name: Sync Kindle Highlights
    on: [push, workflow_dispatch]
    jobs:
      sync-highlights:
        runs-on: ubuntu-latest
        steps:
          - name: Checkout repository
            uses: actions/checkout@v3
    
          - name: Sync highlights
            uses: addnab/docker-run-action@v3
            with:
              image: ghcr.io/arkalim/kindle-to-notion:master
              run: node /code/dist/main.js
              options: |
                -v ${{ github.workspace }}:/code/resources 
                -e BOOK_DB_ID=${{ vars.BOOK_DB_ID }}
                -e NOTION_API_KEY=${{ secrets.NOTION_API_KEY }}
    
          - name: Commit cache changes
            uses: EndBug/add-and-commit@v7
            with:
              message: Commit cache changes
              add: sync.json
    
          - name: Push cache changes
            uses: ad-m/github-push-action@master
            with:
              github_token: ${{ secrets.GITHUB_TOKEN }}
    
  • The above step will trigger a GitHub action to sync the highlights. But, it will fail as you haven't yet setup the NOTION_API_KEY and the BOOK_DB_ID. To do that, go to the GitHub repository settings, click on Secrets and Variables and then click on Actions. Now, create a secret by the name NOTION_API_KEY and a variable by the name BOOK_DB_ID, with their corresponding values as obtained in the previous steps.

  • Now, you need to allow GitHub Action to save the cache (make updates) to the repository. For that, go to repository settings. Click on Actions and then on General. Scroll down to Workflow permissions and select Read and write permissions.

  • You can now manually trigger the GitHub Action by going to the Actions tab in the GitHub repo. This will sync the highlights for the first time and create a sync.json file (cache) in the repository. Afterwards, whenever you want to sync your highlights, just upload the new My Clippings.txt file into your GitHub repo. It will automatically trigger the action to sync the newly added highlights.

For reference on how to setup your repo, take a look at my Kindle Highlights Repo

❗️For Nerds

  • Every highlight made on Kindle is appended at the end of My Clippings.txt
  • Book Name is used as the primary key to facilitate upsert operation in Notion database. So, this field should be left untouched. However, the other fields like Title, Author, Date Started, Date Finished, Satus and Genre could be modified as per your wish.
  • This tool only syncs the new highlights made to each book. If no new highlights have been made, no sync takes place.
  • The info about the last sync is stored in sync.json present in your repository containing My Clippings.txt.
  • In case you wish to sync every book all over again, delete the sync.json file from the repo and delete all the highlights present in your Notion.
  • GitHub Action is used for CICD. Whenever a push is made to the master branch, the Docker image is rebuilt and pushed to GitHub container registry.
  • Your GitHub repo containing My Clippings.txt runs the GitHub action to sync the highlights to Notion everytime you push a change to it. It can also be triggered manually from the Actions tab.

kindle-to-notion's People

Contributors

alfredchenpiano avatar anubhavshrimal avatar arkalim avatar manigandan-dorairaj avatar thaotpphung avatar yedrup avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.