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

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.

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.3.tar.gz (14.7 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.3-py3-none-any.whl (15.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: opds-0.1.3.tar.gz
  • Upload date:
  • Size: 14.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.4.1 CPython/3.13.14 Linux/5.15.154+

File hashes

Hashes for opds-0.1.3.tar.gz
Algorithm Hash digest
SHA256 0f2913148c89b394c258ae84dc93624c816744ef127925be1db9304c28a05f9e
MD5 918f4e96ec71876fbf96af389f884682
BLAKE2b-256 9871eae2c55941e6e845273abc7f15e58ec92a661d264e7065bc2439139d5c69

See more details on using hashes here.

File details

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

File metadata

  • Download URL: opds-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 15.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.4.1 CPython/3.13.14 Linux/5.15.154+

File hashes

Hashes for opds-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 79c1a56572bea34c71cdfb34188d5b549891ea30ccba12c3d71113afa7896416
MD5 599985950fefb5753f6f4a131e613572
BLAKE2b-256 ec427afd964becaef355ff82082c70b167f6a1e4ef03cc8466c422385e06e415

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