A Python-powered tool to scan your physical books into a beautiful web interface using the Open Library API.
Before starting, ensure you have the following installed:
- Python 3.10+
- MySQL or MariaDB
- A hardware barcode scanner or a way to generate text files of ISBNs/Barcodes.
Create a database named biblio. The program will automatically handle table and field creation upon first run.
CREATE DATABASE biblio;Copy the sample configuration file and update it with your local paths and database credentials:
cp create.json.sample create.jsonEdit create.json:
{
"ROOMS_DIR" : "/home/your_user/path_to_room_textfiles/",
"EMAIL" : "your_email@example.com",
"DB_CONFIG": {
"host": "localhost",
"user": "dbuser",
"password": "dbpassword",
"database": "biblio"
}
}Open fetch_book_data.py and update the headers section with your email address. This identifies your requests to Open Library to ensure reliable API access:
headers = {
'User-Agent': 'BiblioLibraryManager/1.0 (your_email@example.com)'
}Setup a clean environment and install dependencies:
# Create and activate environment
python3 -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
# Install requirements
pip install -r requirements.txtThe system organizes books by "Rooms." Each room should have its own .txt file containing barcodes or IDs (one per line).
- Create text files named after your rooms (e.g.,
Office.txt,Kitchen.txt). - Scan your barcodes directly into these files.
- Supported Formats:
- Barcode/ISBN: Simply paste the number.
- Open Library ID: Paste the ID (e.g.,
OL26242482M). If using a "Work" ID, follow it with the wordworks(e.g.,OL26242482M works).
Follow these steps in order to populate your library:
This reads your text files and populates the initial database tables.
python3 load_raw_books.pyCheck for an errors.txt file after running. If it exists, review it for formatting issues.
This calls the Open Library API to retrieve titles, authors, and cover images.
python3 fetch_book_data.pyNote: If a book is missing from Open Library, it will appear in errors.txt. You can manually find the Open Library ID on their website and add it to your room file to try again.
Once your data is loaded, launch the Flask management site:
cd book_sites
python3 app.pyThe terminal will provide a local URL, typically: http://127.0.0.1:5000
- Missing Covers: Open Library does not have every barcode. If a book fails to load, try searching the Open Library website for the ISBN or Work ID manually.
- Database Errors: Ensure the
dbuserhasALL PRIVILEGESon thebibliodatabase.