Create your OPDS catalog with Python
Project description
OPDS python library
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file opds-0.1.2.tar.gz.
File metadata
- Download URL: opds-0.1.2.tar.gz
- Upload date:
- Size: 14.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.3.4 CPython/3.13.13 Linux/5.15.154+
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
64ce7e322675fdc2e2c33c41d91626ff7c27baae2c2c71976ba39ab9d3216a61
|
|
| MD5 |
c1d27818b2bc38e5d124f74689f8d919
|
|
| BLAKE2b-256 |
871426b9425e0f6bd4d51309a2fe01d0b6f5e0094d3a04574da8d573b566f75d
|
File details
Details for the file opds-0.1.2-py3-none-any.whl.
File metadata
- Download URL: opds-0.1.2-py3-none-any.whl
- Upload date:
- Size: 15.2 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
75fdd8a6885edcf41dbdeaf39ede77705736ee5ca32717e1a8b36d49737980a6
|
|
| MD5 |
041dbe4600b33536154adcd1268ef062
|
|
| BLAKE2b-256 |
498464d9bae9a90fdc457201544f1b536fbb0eec045b05045b14374e02631fa8
|