Difference between revisions of "Make library card catalogue PDFs with Python scripts"
Line 2: | Line 2: | ||
* a python virtual environment | * a python virtual environment | ||
* a cloned git repository | |||
* [[calibrestekje]], a python-bindings library | * [[calibrestekje]], a python-bindings library | ||
* a metadata.db file as produced by an installation of [[Calibre]] | * a metadata.db file as produced by an installation of [[Calibre]] | ||
== Getting started == | == Getting started == | ||
Line 15: | Line 15: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
In the <code>bootleg/</code> directory, create a python virtual environment | In the <code>bootleg/</code> directory, create and activate a python virtual environment. Once activated, you'll notice the prompt in the terminal has changed to be prefaced by <code>(venv)</code>, which indicates that the virtual environment is active. | ||
<syntaxhighlight lang="bash" line> | <syntaxhighlight lang="bash" line> | ||
python3 -m venv venv | python3 -m venv venv | ||
source venv/bin/activate | source venv/bin/activate | ||
</syntaxhighlight> | |||
Then, install dependencies in the python environment. | |||
<syntaxhighlight lang="bash" line> | |||
pip install reportlab | pip install reportlab | ||
pip install calibrestekje | pip install calibrestekje | ||
pip install pillow | |||
</syntaxhighlight> | </syntaxhighlight> | ||
Make sure you have a valid <code>metadata.db</code> file, one which is usually produced by Calibre on installation. This file is usually kept with the contents of the Calibre collection. | Make sure you have a valid <code>metadata.db</code> 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: | |||
<syntaxhighlight lang="bash" line> | |||
python3 reportlab_image_poster.py | |||
</syntaxhighlight> | |||
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. | |||
[[Category: Cookbook]] | [[Category: Cookbook]] |
Revision as of 17:33, 20 October 2021
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.