Are you an avid reader? Tend your digital library garden with LibbyToNotion, a Python-based, fully open-source package, that allows you to automatically populate your Notion “Books” database with the ebooks and audiobooks borrowed from your public libraries via Libby by OverDrive.
Table of contents
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 (i.e. automatically), run the script scripts/runLibbyToNotion.sh
at a reasonable frequency using a crontab
job.
GitHub Repository
You can find the all the assosciated code for LibbyToNotion in this github repository
Usage
Libby Timeline Export
- Login to your Libby account in their web app https://libbyapp.com/.
- Go to the Timeline (modify it as needed) and click
Export Timeline
and chooseData (json)
. This will take you to an url. Copy the url and add it tosecrets/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.
Interfacing with Notion
- Register a private integration on your Notion workspace (follow instructions online)
- Obtain its
notionToken
- 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
andgetNotionPageEntryFromProp
inlib/port_utils.py
.
Title property: Name
Text properties: Author, ISBN
Select properties: Status, Format
Date properties: LibbyDate
- Get its
databaseID
and add it tosecrets/secrets_notion.json
in the following format:
{
"notionToken": "your notion token",
"databaseID": "your notion database ID"
}
Running the script
- Create a python conda env using
requirements.txt
- Run the python script
src/libbyToNotion.py
with--fullLibby
argument asTrue
. Note that this will automatically set theStatus
of all items from Libby to belibby-inbox
. - 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
toFalse
and populating theelse
block which currently showsNotImplementedError
). 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
toTrue
and--fullLibby
toFalse
. - 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 .
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