A Python library for generating OPDS 2.0 compliant feeds
Project description
opds2.0
A Python library for generating OPDS (Open Publication Distribution System) 2.0 compliant feeds using Pydantic and type hints.
Based on the OPDS 2.0 specification.
Installation
This package is not yet on PyPI. Install directly from GitHub:
pip install git+https://github.com/ArchiveLabs/opds2.0.git
Running Tests
pytest tests/ -v
Developer's Guide
To use this library, you must implement two key classes:
- DataProvider: Defines how to search and retrieve records. You must subclass and implement the
searchmethod. - DataProviderRecord: Defines the structure of a single record in your catalog. You must subclass and implement the
metadata,links, andimagesmethods.
Example
from pyopds2 import Catalog, DataProvider, DataProviderRecord, Metadata, Link
class MyRecord(DataProviderRecord):
def metadata(self):
return Metadata(title="Example Book")
def links(self):
return [Link(href="/books/1", rel="self", type="application/epub+zip")]
def images(self):
return None
class MyProvider(DataProvider):
@staticmethod
def search(query, limit=50, offset=0, sort=None):
records = [MyRecord()]
# Return a list of MyRecord instances and total count
return MyProvider.SearchResponse(
MyProvider,
records=records,
total=len(records),
query=query,
limit=limit,
offset=offset,
sort=sort
)
catalog = Catalog.create(MyProvider.search("example"))
catalog.model_dump_json()
See examples/openlibrary.py for a real-world integration with OpenLibrary.
API Reference
Core Models
Catalog: Represents an OPDS 2.0 catalog/feedPublication: Represents a publication (book, audiobook, etc.)Metadata: Metadata for catalogs and publicationsLink: Links to resourcesContributor: Authors, illustrators, publishers, etc.Navigation: Navigation links for browsing
Catalog Functions
Catalog(): Create a basic catalogCatalog.create(): Run a search and create a paginated Catalog from the search results
Similar Implementations
This library was inspired by The Palace Project's OPDS implementation.
License
AGPLv3 License. See LICENSE for details.
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 pyopds2-0.1.0.tar.gz.
File metadata
- Download URL: pyopds2-0.1.0.tar.gz
- Upload date:
- Size: 22.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e6493c1ec6e0ca555ee27eae2f55a27982e430b701a16788913ad349a661ce23
|
|
| MD5 |
6c69d51e2f474c7622278b0a0494f05d
|
|
| BLAKE2b-256 |
cd743f2430a6c84ddbdcd43c786a0401e004fd6072b4c8543fe2cce5b7edd451
|
File details
Details for the file pyopds2-0.1.0-py3-none-any.whl.
File metadata
- Download URL: pyopds2-0.1.0-py3-none-any.whl
- Upload date:
- Size: 19.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7f1cac263050e2a349c6108fc695fe40dbf76f9c888f79cef052c2a51750ece6
|
|
| MD5 |
01ef154a00bdda5755faddbad9a25d49
|
|
| BLAKE2b-256 |
49c8e0bd66ce12b158e25a94e4d14a626675ac2c4eba6c6c501f10e9ed5961ff
|