Metadata-Version: 2.4
Name: ovos-skill-opds-books
Version: 0.1.0a1
Summary: Reads books aloud from e-book catalogs - any OPDS catalog (1 or 2), or a feed of books such as Standard Ebooks' new releases. A provider for the common reading pipeline.
Author: Andreas Lorensen
License: Apache-2.0
Project-URL: Homepage, https://github.com/emkay-voice/ovos-skill-opds-books
Project-URL: Issues, https://github.com/emkay-voice/ovos-skill-opds-books/issues
Project-URL: Emkay, https://github.com/emkay-voice/emkay
Project-URL: Reading pipeline, https://github.com/andlo/ovos-common-reading-pipeline-plugin
Project-URL: Icon, https://raw.githubusercontent.com/emkay-voice/ovos-skill-opds-books/main/icon.png
Keywords: ovos,openvoiceos,skill,voice,assistant,reading,books,ebooks,opds,epub,standard-ebooks,common-reading,emkay
Classifier: Development Status :: 3 - Alpha
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Intended Audience :: End Users/Desktop
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Multimedia :: Sound/Audio :: Speech
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: ovos-workshop<10.0.0,>=0.0.15
Requires-Dist: ovos-utils>=0.0.38
Requires-Dist: ovos-bus-client>=0.0.8
Requires-Dist: requests
Requires-Dist: beautifulsoup4
Requires-Dist: pypdf>=4
Requires-Dist: python-docx>=1.0
Provides-Extra: test
Requires-Dist: pytest; extra == "test"
Requires-Dist: ovos-common-reading-pipeline-plugin; extra == "test"
Dynamic: license-file

# <img src='icon.png' card_color='#2E8B6E' width='50' height='50' style='vertical-align:bottom'/> OPDS Books

Reads books aloud from e-book catalogs: any [OPDS](https://opds.io) catalog (OPDS 1 or 2), or a plain Atom/RSS feed
of books, such as [Standard Ebooks](https://standardebooks.org)' new releases.

It is a provider for the [common reading pipeline](https://github.com/andlo/ovos-common-reading-pipeline-plugin),
like the fairy-tale, article and [documents](https://github.com/emkay-voice/ovos-skill-documents) providers. A book
reads the way a story does: it is announced, read a sentence at a time, paused, and continued where it stopped. With
the pipeline's `"player": "ovos-media"`, it is read through the media player and has that player's controls.

Made for [Emkay](https://github.com/emkay-voice/emkay), and meant for any OpenVoiceOS device.

## Usage

- "Read me the book Ivanov"
- "Read the novel Confessions of Zeno"
- "Read a book from Standard Ebooks" (a catalog by its name)
- "Read me a book" / "Read my books" (a book picked at random)
- "Læs bogen Den grimme ælling"
- "Pause", "continue" and "stop", as for any reading

It understands "book", "e-book", "novel" and "my books" in English, Danish, German, Spanish, French, Italian, Dutch
and Portuguese. A book is read in its own language; nothing is translated. Books in the device's language are found
first. A book with no language of its own takes the catalog's (see below), or English.

## Catalogs

In the skill's settings, one catalog per line:

```
url | name | username | password | language
```

Every field except the url can be left out:

```
https://standardebooks.org/feeds/atom/new-releases | Standard Ebooks
https://example.org/opds | Min bogreol | | | da
```

- The **name** is what you call the catalog ("a book from Min bogreol").
- The **username and password** are sent only to the catalog's own site.
- The **language** is used for books whose catalog does not give one.

The skill reads the catalogs at start and then every `refresh_hours` (24 by default), in the background. It follows a
catalog's shelves and pages on its own site, at most 60 pages and 5000 books. It keeps the list, not the books.

### Standard Ebooks

The default catalog is Standard Ebooks' **new releases** feed. It is open to everyone, and the books are free (CC0).
Their full catalog, `https://standardebooks.org/feeds/opds`, and their search are for members of their
[Patrons Circle](https://standardebooks.org/donate#patrons-circle). If you are a member, add it with your email as
the username and an empty password:

```
https://standardebooks.org/feeds/opds | Standard Ebooks | you@example.com |
```

### Other catalogs

Any OPDS catalog works: a Calibre content server (`http://host:8080/opds`), Kavita, Komga, COPS, or an OPDS 2
catalog. Books are read from EPUB first, and from PDF, HTML or text when a book has no EPUB.

[Margin](https://marginpaper.com) has an open OPDS catalog, but its `robots.txt` disallows `/download/`, so it is not
among the defaults. Whether to add it is up to you. The skill downloads a book only when someone asks to hear it, as
an e-reader app does.

## Being polite to catalogs

- `robots.txt` is honoured when the skill reads a catalog on its own. A book someone asks to hear is fetched
  like an e-reader app fetches it.
- When a site answers "too many requests" or "unavailable", the skill waits as long as its `Retry-After` header asks.
- A book is downloaded only when it is asked for. Its text is kept, so it is not downloaded again for the next
  chapter.
- Requests carry a `User-Agent` that names the skill.

## Searching

A request is first matched against the titles the skill already knows. When nothing matches well, it asks every
catalog that can search (OpenSearch) and waits at most 1.5 seconds, inside the pipeline's 2. Standard Ebooks' search
needs Patrons Circle access, as above.

## What is read

The book itself, from its first chapter. The edition's own pages are left out: title page, imprint, colophon,
copyright page, tables of contents, notes and note markers (EPUB `epub:type`). Paragraphs, headings and list items
are read in order. A table row is read as one line with its cells joined by ": ", which is how a play is set, so it
sounds like "Ivanov: I am reading… presently."

## Install

```bash
pip install ovos-skill-opds-books
```

Like every reading provider, it needs
[ovos-common-reading-pipeline-plugin](https://github.com/andlo/ovos-common-reading-pipeline-plugin) in the intent
pipeline.

## Development

```bash
pip install -e ".[test]"
pytest -c tests/pytest.ini tests
```

The tests serve their own small catalogs: OPDS 1 with shelves and pages, a Standard Ebooks-style Atom feed, RSS, and
OPDS 2. They also build their own books, so nothing is fetched. `test_with_the_pipeline.py` uses the real reading
pipeline to check that the requests above are understood, and that "book a table" and the like are left to their own
skills.

`extract.py` is the same as in ovos-skill-documents; change both together.

## Category
**Entertainment**

## Tags
#books #ebooks #opds #reading #epub #standardebooks #commonreading #provider
