Skip to main content

Create your OPDS catalog with Python

Project description

OPDS python library

PyPI - Downloads PyPI - Version PyPI - Python Version PyPI - License Pipeline

This package allows you to easily compose an OPDS version 1.2 catalog.

No reason to touch any xml yourself, everything is wrapped in semantic Python classes.

Installation

Install from PyPI

pip install opds

Usage

First of all check out the the official OPDS catalog spec documentation.

It has a lot of useful and instructive examples that will help you understand what to add to your catalog.

A single OPDS catalog file is represented by the OPDSCatalog class

opds_catalog = opds.OPDSCatalog(title="Example")

The catalog comes with all required metadata configured by initialization. It is stored in the metadata member, you can use all methods of the list container to add more.

For example

summary = opds.Metadata(name="summary", value="An example OPDS catalog")
opds_catalog.metadata.append(summary)

Every catalog comes with 3 default namespaces: Atom (default), DublinCore (dc) and OPDS (opds). Add more by adding them to the attributes of the OPDSCatalog. You typically won't need to.

As special type of metadata one typically wants to add links for navigation to other catalogs of the same server. For quality of life there are Link subclasses for the most common link types.

other_catalog_link = opds.AcquisitionFeedLink(href="/other-catalog", rel=Link.Rel.SUBSECTION)
self_link = opds.NavigationFeedLink(href="/this-url", role=Link.Rel.SELF)
start_link = opds.NavigationFeedLink(href="/root-url", role=Link.Rel.START)
opds_catalog.links.extend([ other_catalog_link, self_link, start_link ])

The difference between navigation and acquisition feeds is explained in the OPDS spec.

After all metadata is defined, we add the entries to the catalog.

entry_1 = opds.Entry(title="Book 1", uid="book_1")
opds_catalog.entries.append(summary)

Entries hold metadata and links just like the catalog. Adding and manipulating them is completely analogous.

After everything is set up, write the catalog to xml bytes

opds_bytes = opds_catalog.write()

Done.

Disclaimer

There was no AI used in creating this package. Every single line was typed by human hand.

The source code was originally created for the Cata-Log project and later externalized for use across other projects.

License

This software is proudly released under the GNU Affero General Public License v3.0 or later (AGPLv3) open-source license.

Any contributions will be subject to the same licensing.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

opds-0.1.1.tar.gz (14.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

opds-0.1.1-py3-none-any.whl (15.0 kB view details)

Uploaded Python 3

File details

Details for the file opds-0.1.1.tar.gz.

File metadata

  • Download URL: opds-0.1.1.tar.gz
  • Upload date:
  • Size: 14.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.3.4 CPython/3.13.13 Linux/5.15.154+

File hashes

Hashes for opds-0.1.1.tar.gz
Algorithm Hash digest
SHA256 057ca6e37faf1ba7845997650e4b3d9f9fa8476e7feedf3c0587d224fcab293d
MD5 bd0e68c197a9ed67bd0978b72e3b874d
BLAKE2b-256 d48c81c48289c2c9e210f4aa99400aa32fa856b33b592c15d7ad9401b72493f3

See more details on using hashes here.

File details

Details for the file opds-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: opds-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 15.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.3.4 CPython/3.13.13 Linux/5.15.154+

File hashes

Hashes for opds-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ccc6ba777e7a89aae6295382fcb930ff03cbe4ab47b958c28d57d25ef10166c5
MD5 47339140e869cbb8e3cfba6829a52cf4
BLAKE2b-256 7d6aa9bdccdb41f12827368c7f16d63b215bb6967f5f62d5383249ddfa5ded35

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page