Giter Club home page Giter Club logo

libbytonotion's Introduction

Libby To Notion

LibbyToNotion

Description

This project allows you to populate your Notion "Books" database with ebooks / audiobooks borrowed via Libby using the Notion API and the Libby Timeline Export. If you'd like this to happen periodically, run the script scripts/runLibbyToNotion.sh at a reasonable frequency using a crontab job.

Directory Structure

.
+-- docs/
|   +-- images/
|   |   +-- demo.png
|   |   +-- icon.png
+-- globalStore/
|   +-- constants.py
+-- lib/
|   +-- port_utils.py
|   +-- utils.py
+-- notebooks/
|   +-- Trial.py
+-- scripts/
|   +-- runLibbyToNotion.sh
+-- secrets/
|   +-- secrets_notion.json
|   +-- secrets_libby.json
+-- src/
|   +-- libbyToNotion.py
+-- tests/
|   +-- testNotionAPI.py
|   +-- testLibbyDataRetrieval.py
+-- .gitignore
+-- juyptext.toml
+-- LICENSE
+-- README.md
+-- requirements.txt
+-- STDOUTlog_examples.txt

LibbyToNotionScreenshot

Usage

  1. Login to your Libby account in their web app https://libbyapp.com/.
  2. Go to the Timeline (modify it as needed) and click Export Timeline and choose Data (json). This will take you to an url. Copy the url and add it to secrets/secrets_libby.json in the following format:
{
    "url": "add the timeline json url here"
}

Note: Remember to click Export Timeline -> Data (json) often as you borrow books via Libby. This is to synchronize your account with the URL.

  1. Register a private integration on your Notion workspace (follow instructions online)
  2. Obtain its notionToken
  3. Create a database / choose existing database on Notion to contain all the entries from Libby. Make sure it has the following properties. If you want to add more properties or remove, modify the function getAllLibbyItems and getNotionPageEntryFromProp in lib/port_utils.py.
Title property: Name
Text properties: Author, ISBN
Select properties: Status, Format
Date properties: LibbyDate
  1. Get its databaseID and add it to secrets/secrets_notion.json in the following format:
{
    "notionToken": "your notion token",
    "databaseID": "your notion database ID"
}
  1. Run the python script src/libbyToNotion.py with --fullLibby argument as True. Note that this will automatically set the Status of all items from Libby to be libby-inbox.
  2. Currently, the logic takes in all unique borrowed items from the Libby Timeline, gets all the rows from the Notion database, and verifies that items aren't repeated. This can be made more efficient if needed by filtering out only recently added items from the Timeline (set --fullLibby to False and populating the else block which currently shows NotImplementedError). But for now, it is simpler to just modify it locally after getting all items from the Timeline on Libby. To do a one time cover update, set argument --oneTimeCoverUpdate to True and --fullLibby to False.
  3. You can periodically run this file again as a script scripts/runLibbyToNotion.sh using a crontab job to get periodic updates. For more information on Crontab, check out this reference.

Requirements

You can install all the requirements using the following command:

pip install -r requirements.txt
pip install -e .

Sources

If you use it in your work and want to adapt this code, please consider starring this repo or forking from it!

@misc{nanbhas2022_libbyToNotion,
  title={Libby To Notion},
  author={Nandita Bhaskhar},
  howpublished={GitHub Repo, https://github.com/nanbhas/LibbyToNotion},
  year={2022}
}

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.