Skip to main content

No project description provided

Project description

library2notion

PyPI version Python Version

A tool to create a library on Notion with all your books (digital or not) in order to make it easier to find them, add comments, priorities, filter by type or category and keep track of read ones.

Main features:

  • Detects all digital books from a given path and all the subfolders.
  • Adds, updates or deletes entries on Notion DB to match the status of the local folder.
  • Possibility to create a simple .paper file to add non-digital to be tracked as well.
  • Extracts metadata from .pdf and .epub files.

Installation

Using portable binary

Download the latest binary release.

With Homebrew (Recommended for macOS)

$ brew install helguera/tap/library2notion

With PIPX (Recommended for Linux & Windows)

$ pipx install library2notion

With PIP

$ pip install --user library2notion

Python 3.7 or later required.

From source

This project uses poetry for dependency management and packaging. You will have to install it first. See poetry official documentation for instructions.

$ git clone https://github.com/helguera/library2notion.git
$ cd library2notion/
$ poetry install
$ poetry run library2notion

Usage

$ library2notion --help
usage: library2notion [-h] -p PATH [-l LOGFILEPATH] [-e EXTENSIONS [EXTENSIONS ...]] [-t NOTIONTOKEN] [-u NOTIONDBURL] [-f] [-o OUTPUTFOLDER]

library2notion created by Javier Helguera (github.com/helguera) © 2023 MIT License

general options:
  -p, --Path PATH                    Path where to start looking for books. It will also check all subfolders
  -t, --NotionToken NOTIONTOKEN      Notion token
  -d, --NotionDbId  NOTIONDBURL      Notion database id
  -f, --Formats     FORMATS          List of formats to be taken into account. At this moment .PDF, .EPUB and .PAPER are supported.
  -only_new,                         Only check new books
  -only_updated                      Only check changes in existing books (does not include removals)
  -only_deleted                      Only check deleted books
  -h, --help                         Show this help message and exit

Input

-p, --Path

The path where to look for files (and subfolders). It is higly recommended to use relative paths. This is really important since it will also be used to generate the tags of each book. (Take a look at "Metadata" section for further info).

For example, if your library looks like:

/home/your_user/Documents/books/Programming/Python
/home/your_user/Documents/books/Programming/C
/home/your_user/Documents/books/History/Spanish History

They ideal way to proceed is, first, move to books folder, since it is the common one for all books.

cd /home/your_user/Documents/books

And from here, execute l2n with a relative path:

library2notion -p "./"

They way a book is uniquely identified is by using its path. This is important because the book ./books/Programming/Python/PythonCookbook will be treated as a different one from ./Programming/Python/PythonCookbook.

-t, --NotionToken

It is the secret token from Notion when an itegration is created. Visit the official docs for further info. Don't forget to give your integration page permissions.

-d, --NotionDbId

The id of the Notion database where all info will be uploaded. This database has to exist in advance and the columns it needs to have are fixed and can't be changed. These are:

Column Name Type
File Name Title
Title Text
Priority Select
Status Select
Format Multi-select
Tags Multi-select
Comments Text
Author Text
Publisher Text
ISBN Text

To get the database ID value, open the database as a full page in Notion. Use the Share menu to Copy link. Now paste the link in your text editor so you can take a closer look. The URL uses the following format:

https://www.notion.so/{workspace_name}/{database_id}?v={view_id}

-f, --Formats

These are the formats that will be taken into account. At this moment, .epub, .pdf and .paper are supported and used by default.

library2notion -f EPUB PAPER  -> only look for .epub and .paper files
library2notion -f PDF         -> only look for .pdf files

-only_new

Checks only new books that have been added to the path since the last execution. Skips updated and deleted ones.

-only_updated

Checks only books that have been updated since the last execution. Skips new and deleted ones.

-only_deleted

Checks only books that have been deleted since the last execution. Skips new and updated ones.

Metadata

The tool will extract the following data to upload to Notion:

  • File Name: is the full path to the file. It is used as primary key of the table in Notion, so it can't be duplicated.
  • Title: title of the book.
  • Tags: the categories of the book. They are generated automatically from the path. For example, if the path is ./Tech Books/Programming/Python/mybook.pdf, the tags will be Tech Books, Programming, Python.
  • Author: the author or authors of the book.
  • Publisher: the publisher of the book.
  • Formats: the available formats of the book. A book available in multiple formats will only appear once in the database.
  • ISBN: the ISBN.

Non-digital books (.paper)

With update 0.2.0, the tool supports non-digital books. You just have to create a .paper file in a folder per non-digital book that you want to add with the following content:

{
    "Title": "",
    "Author": "",
    "Publisher": "",
    "ISBN": ""
}

Log Files

A log file will be created after each execution in folder ./library2notion-logs. It will include info about created, updated and deleted books.

Examples

First example

Second example

Third example

Getting help

If you found a bug or have a feature request, please open a new issue.

If you have a question about the program or have difficulty using it, you are welcome to the discussions page. You can also mail me directly at javier@javierhelguera.com, I'm always happy to help.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

library2notion-1.0.2.tar.gz (12.4 kB view details)

Uploaded Source

Built Distribution

library2notion-1.0.2-py3-none-any.whl (13.6 kB view details)

Uploaded Python 3

File details

Details for the file library2notion-1.0.2.tar.gz.

File metadata

  • Download URL: library2notion-1.0.2.tar.gz
  • Upload date:
  • Size: 12.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.10.12 Linux/6.2.0-39-generic

File hashes

Hashes for library2notion-1.0.2.tar.gz
Algorithm Hash digest
SHA256 8b2140af0aad1797222431befc095700c002e1faa8197fd2b0256bfb84a2ff6a
MD5 625c7774710f3c2ba01cbedac30a6fc7
BLAKE2b-256 11b0b0109c9f3bbae4dd9917ee2edfd69fda953ddbe59e17c6a1582786246796

See more details on using hashes here.

File details

Details for the file library2notion-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: library2notion-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 13.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.10.12 Linux/6.2.0-39-generic

File hashes

Hashes for library2notion-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 3e3514080d2b0bdff6339ea9bb666581b0cb1d04530fe5acd252845bb05cce1d
MD5 6342b5ff0b62df749ac643327ee7dabf
BLAKE2b-256 4912fcf54c4a0642c9938ce2d0e6e1bd356753403b1a0f7f78864aca4004f55c

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page