Skip to main content

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

Note

This package will remain functional and safe without regular updates.

This package has NO dependencies. Also OPDS1.2 is a stable standardized format.

Therefore the only activity on this repo will be features and fixes. If there is low or no activity that does not indicate security or usability deficits.

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.

Metadata

Release files for opds 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for opds 0.1.3
File Size Uploaded
opds-0.1.3.tar.gz 14.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for opds 0.1.3
File Interpreter ABI Platform
opds-0.1.3-py3-none-any.whl Python 3 none any Details

Total release size: 29.9 kB

Release files / opds-0.1.3.tar.gz

Download URL opds-0.1.3.tar.gz
Size 14.7 kB
Tags Source
SHA-256 checksum
How to use checksums
0f2913148c89b394c258ae84dc93624c816744ef127925be1db9304c28a05f9e
BLAKE2b-256 checksum
How to use checksums
9871eae2c55941e6e845273abc7f15e58ec92a661d264e7065bc2439139d5c69
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.4.1 CPython/3.13.14 Linux/5.15.154+

Release files / opds-0.1.3-py3-none-any.whl

Download URL opds-0.1.3-py3-none-any.whl
Size 15.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
79c1a56572bea34c71cdfb34188d5b549891ea30ccba12c3d71113afa7896416
BLAKE2b-256 checksum
How to use checksums
ec427afd964becaef355ff82082c70b167f6a1e4ef03cc8466c422385e06e415
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.4.1 CPython/3.13.14 Linux/5.15.154+

Release history Release notifications | RSS feed

This release

0.1.3 This release

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page