clach04 / webook_server

💩📖 Worst E-book server - light weight OPDS and web server that converts ebook formats on the fly, using Python (2 or 3) and optional Calibre convert
GNU General Public License v3.0
5 stars 0 forks source link
ebook-convert ebook-converter epub ereader ereader-tools kindle mobi opds opds-catalog opds-feed opds-generator python

-- coding: utf-8 --

webook_server - Worst E-book server

Home page https://github.com/clach04/webook_server

Table Of Contents

Table of contents generated with markdown-toc

Overview

This is either:

Basic ebook server that doesn't require a database.

Given a directory of (possibly directories of) ebooks serve a web (http) interface of the files and automatically convert to the desired format (incomplete examples; mobi, epub, fb2, html, txt, rtf, etc.). The format is specified in the URL and browsing is supported. This works great with a web browser (including the Amazon Kindle Experimental Web Browser) and OPDS client like KOReader.

Features

Comes with:

Alternatives

The closest equivilents of this tool are KindleGate which only supports conversion to mobi and https://github.com/dubyte/dir2opds.

Also take a look at:

Getting Started

Either use Operating System packages or Python packages

Debian/Ubuntu install dependencies

For Python 2.x deployment:

sudo apt install calibre

For Python 3.x deployment (with calibre ebook-convert exe - likely Python2):

sudo apt install calibre

Python install dependencies

NOTE Currently relies on Calibre ebook-convert (not documented in the Python dependency install notes below).

ONLY needed for the web browser version, not needed for OPDS

If installing/working with a source checkout issue:

pip install -r requirements.txt

Run

cp example_config.json config.json
# Optional; edit config.json with "ebook_dir" (defaults to ./ if omitted) and "temp_dir" (will use OS environment variable TEMP if omitted, if that's missing system temp location) location
python webook_server.py

Then open a browser to http://localhost:8080/... or issue:

curl http://localhost:8080/....

Sample Run

  1. Download the sample_reading_media.zip from https://github.com/clach04/sample_reading_media/releases/tag/v0.1
  2. Extract to local directory, ideally into a directory called sample_reading_media
  3. Create a (or edit existing) config file, for example named sample_reading_media.json

    {
        "ebook_dir": "sample_reading_media"
    }

if setting tmp dir, mkdir -p /tmp/ebookserver/....

  1. Run the server with the config file:

    python webook_server.py sample_reading_media.json
  2. Open Web browser to http://127.0.0.1:8080/ and browse around, for example download

systemd webook service

Systemd service (e.g. for Raspbian).

For more information see:

NOTE directory name for ExecStart and WorkingDirectory in webook.service.

Install

# Potententially edit service; ExecStart, WorkingDirectory, User
# Review config file
sudo cp scripts/webook.service /etc/systemd/system/webook.service
sudo chmod 644 /etc/systemd/system/webook.service
sudo systemctl enable webook.service

Usage

sudo systemctl stop webook.service
sudo systemctl start webook.service
sudo systemctl restart webook.service
sudo systemctl status webook.service  # status and recent logs
sudo systemctl status webook.service -n 100  # show last 100 log entries
journalctl  -u webook.service  # show all logs

systemctl list-unit-files --state=enabled | grep webook

NOTE if changing service files, e.g. adding Environment, restart config (not just specific service):

sudo systemctl daemon-reload
sudo systemctl restart webook.service

Notes and config

json config file

Operating System Environment Variables

https / TLS / SSL support

Known working environments

Known to work under Linux with

Debian / Ubuntu / Armbian

DISTRIB_DESCRIPTION="Ubuntu 20.04.3 LTS" NAME="Ubuntu" VERSION="20.04.3 LTS (Focal Fossa)" ID=ubuntu ID_LIKE=debian PRETTY_NAME="Armbian 21.08.6 Focal" VERSION_ID="20.04"

Debian GNU/Linux 9 (stretch)

With:

Using the OS packages for Python and Calibre.

Microsoft Windows

cURL client

For testing. By default cURL will be detected by webook_opds_server.py as an OPDS client (rather than as a web browser), this can be influenced via the http accept header.

curl -v --header "ACCEPT: /" # NOTE this happens to be the default so this is not actually needed curl -v --header "ACCEPT: text/html" # convince OPDS server this client is a web browser