1
0
Fork
You've already forked EbookTools
0
unfinished, work in progress
  • Jupyter Notebook 90.4%
  • Python 9.6%
2026年04月23日 09:33:37 +02:00
Resources TibTests 2025年02月20日 09:34:42 +01:00
wiki_timelines_exporters irl 2025年12月17日 09:51:33 +01:00
.gitignore cleanup exporters 2025年12月16日 08:46:36 +01:00
.python-version py3.14 2026年01月10日 21:51:41 +01:00
ai_search.py mddl 2025年03月11日 12:56:27 +01:00
calibre_tools.py Harcopy case 2025年11月13日 15:18:31 +01:00
calibre_tools_localization.py tps 2025年01月31日 16:35:55 +01:00
conv.py typing mess of sdl 2025年02月20日 14:53:37 +01:00
ebook_tools.py tps 2025年05月28日 11:04:18 +02:00
ebook_utils.py tps 2025年01月31日 11:34:26 +01:00
indra_tools.py typed out 2025年02月01日 15:52:48 +01:00
kindle_tools.py typed out 2025年02月01日 15:52:48 +01:00
kindle_tools_localization.py en,de locales for kindle-clippings mess 2024年04月05日 19:12:12 +02:00
md_tools.py unmess 2026年03月10日 09:39:18 +01:00
metadata.py typed out 2025年02月01日 15:52:48 +01:00
pgl.py cln 2025年05月11日 18:04:59 +02:00
pyproject.toml upd 2025年06月16日 17:50:59 +02:00
README.md Module description 2026年04月23日 09:33:37 +02:00
time_lines.py tps 2025年05月28日 11:04:18 +02:00
uv.lock ong 2026年03月25日 13:52:19 +01:00

EbookTools

EbookTools is a collection of Python-based utilities for managing ebook libraries, extracting metadata, processing highlights, and generating temporal data (timelines) from various sources.

Note

This project is currently under active development. The documentation focuses on the project structure and component modularity to facilitate reuse and further development.

Project Structure

The project is organized into several functional components designed to be modular and reusable.

Core Utilities

  • ebook_utils.py: Common utility functions, including text sanitization for file systems and Unicode-based progress bar generation.
  • metadata.py: A unified interface for extracting metadata from PDF and EPUB files using pypdf and lxml.

Platform & Device Integrations

  • calibre_tools.py: Tools for interfacing with Calibre libraries, including loading metadata from metadata.db (XML export) and exporting books/metadata to structured formats.
  • kindle_tools.py: Parser for Kindle clippings (My Clippings.txt). It handles the complex, locale-specific formatting of highlights and notes.
  • localization: Support files like calibre_tools_localization.py and kindle_tools_localization.py provide locale-specific string mappings.

Content & Markdown Processing

  • md_tools.py: Utilities for working with Markdown files, specifically focused on extracting and generating Markdown tables with embedded YAML metadata.
  • conv.py: LaTeX to SVG conversion utility using matplotlib, useful for rendering formulas in ebook contexts.
  • ai_search.py: Implements document search using sentence embeddings. It leverages sentence_transformers and torch to index and query document content based on semantic similarity.

Timelines & Historical Data

  • time_lines.py: Core logic for processing and filtering temporal events. It integrates with indralib for advanced time handling (BP, BC, geological scales).
  • wiki_timelines_exporters/: Scripts and notebooks for scraping and exporting timeline data from Wikipedia.

Experimental & UI

  • pgl.py: A low-level graphics/UI abstraction layer built on sdl2 (PySDL2).
  • indra_tools.py: Integration points for the Indra data ecosystem.

Component Reuse

Most modules are designed to be imported independently:

  • Metadata Extraction: Use Metadata from metadata.py for a simple EPUB/PDF metadata API.
  • Kindle Parsing: Use KindleTools from kindle_tools.py to parse clipping files into JSON-like structures.
  • Markdown Tables: Use MdTools from md_tools.py to parse or generate Markdown files with rich metadata.
  • Semantic Search: Use ai_search.py as a standalone library for embedding-based local search.

Configuration

The main entry point (ebook_tools.py) uses a configuration file located at ~/.config/EbookTools/ebook_tools.json. It defines paths for:

  • Calibre Library
  • Kindle Clippings
  • Metadata Library
  • Notes (Markdown) repository

Key Dependencies

The project uses uv for dependency and environment management.

  • PDF/EPUB: pypdf, lxml, pymupdf
  • NLP/AI: sentence-transformers, torch, einops, numpy
  • Data Analysis: pandas, polars, pyarrow
  • Graphics & UI: PySDL2, matplotlib, pillow
  • Utilities: beautifulsoup4, pyyaml, rich, pycryptodome
  • Notebooks: jupyterlab

Setup & Development

Since this is an ongoing project, it is recommended to use uv to manage the environment:

# Install dependencies
uv sync
# Run the main tool
uv run ebook_tools.py --help

Main Entry Point

The CLI orchestrator is ebook_tools.py. It supports various actions:

python ebook_tools.py export|notes|kindle|indra|meta|timeline|bookdates [options]

Action Overview

  • export: Copies books from Calibre to the local repository.
  • notes: Syncs Calibre metadata to Markdown notes.
  • kindle: Parses connected Kindle clippings.
  • meta: Bulk metadata extraction test.
  • timeline / bookdates: Processes temporal data from notes and Calibre.

Roadmap & Potential Reuses

  • Modular Parsers: The KindleTools and Metadata classes can be extracted for use in other ebook-related projects.
  • Indra Integration: Ongoing work to bridge ebook metadata with the Indra event/temporal database.
  • AI Search: The ai_search.py module provides a foundation for a local RAG (Retrieval-Augmented Generation) system for personal libraries.