Make library card catalogue PDFs with Python scripts

From Parallel Library Services
Jump to navigation Jump to search

This recipe depends on the installation of

  • a python virtual environment
  • a cloned git repository
  • calibrestekje, a python-bindings library
  • a metadata.db file as produced by an installation of Calibre

Getting started

First, clone the git and change to the new bootleg/ directory:

git clone https://git.xpub.nl/simoon/bootleg.git
cd bootleg/

In the bootleg/ directory, create and activate a python virtual environment. Once activated, you'll notice the prompt in the terminal has changed to be prefaced by (venv), which indicates that the virtual environment is active.

python3 -m venv venv
source venv/bin/activate

Then, install dependencies in the python environment.

pip install reportlab 
pip install calibrestekje
pip install pillow

Make sure you have a valid metadata.db file in the same directory, one which is usually produced by Calibre on installation. This file is usually kept with the contents of the Calibre collection.

Next, run this command:

python3 reportlab_image_poster.py

This will produce a PDF, and also a list of the contents. In my case, it produced a 1048 page PDF in seconds, with the title and author of each book on separate pages of a card catalogue.