Skip to content

About

OPDS Client Library for Python

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

OPDS Client

opds-client

A Python library for working with OPDS catalogs, supporting both OPDS 1.2 (Atom/XML) and OPDS 2.0 (JSON) specifications.

PyPI version PyPI downloads Python 3.10+ License: MIT CI - Mainline CI - Features Code style: ruff

Features · Installation · Quick Start · Authentication · Models · Usage Examples · OPDS 1.2 vs OPDS 2.0 · Testing · Documentation · Project Structure · License


Features

OPDS 2.0 (JSON)

  • ✅ Parse OPDS 2.0 feeds and publications
  • ✅ Validate against OPDS 2.0 specification
  • ✅ Navigate navigation, publications, groups, and facets collections
  • ✅ Handle pagination (first, previous, next, last links)
  • ✅ Search catalogs with URI template resolution
  • ✅ Work with acquisition links (download, buy, borrow, etc.)
  • ✅ HTTP error handling with retries
  • ✅ Pydantic models for type safety

OPDS 1.2 (Atom/XML)

  • ✅ Parse OPDS 1.2 Atom feeds and entries
  • ✅ Dublin Core metadata support
  • ✅ Navigation and Acquisition feeds
  • ✅ Facet groups with active facets and item counts
  • ✅ Acquisition links with prices and indirect acquisitions
  • ✅ OpenSearch integration
  • ✅ Multiple acquisition relations (buy, borrow, subscribe, etc.)

Installation

pip install opds-client

Quick Start

OPDS 2.0 (JSON)

from opds_client import OPDS2Client

# Create a client
client = OPDS2Client()

# Fetch a feed
feed = client.fetch_feed("https://example.com/opds")

# Access feed metadata
print(f"Title: {feed.metadata.title}")
print(f"Publications: {len(feed.publications or [])}")

# Navigate navigation links
for nav in feed.navigation or []:
    print(f"- {nav.title}: {nav.href}")

# Search
results = client.search(feed, "query")

OPDS 1.2 (Atom/XML)

from opds_client import OPDS12Client

# Create a client for OPDS 1.2
client = OPDS12Client()

# Fetch a feed (XML format)
feed = client.fetch_feed("https://example.com/opds.xml")

# Access feed metadata
print(f"Title: {feed.title}")
print(f"Entries: {len(feed.entries or [])}")

# Navigate navigation links
start_link = feed.get_start_link()

# Get acquisition links from entries
if feed.entries:
    entry = feed.entries[0]
    acq_links = entry.get_acquisition_links()

Documentation

The full documentation is available at: https://sevdani.github.io/opds-client

Testing

# Install dev dependencies
pip install -e ".[dev]"

# Run tests
pytest

# Run with coverage
pytest --cov=opds_client

# Run type checks
mypy opds_client

# Run linter
ruff check .

Building Documentation Locally

# Install docs dependencies
pip install -e ".[docs]"

# Build with Zensical
zensical build

# Preview with Zensical
zensical serve

License

License: MIT

MIT License - see LICENSE file for details.

References

About

OPDS Client Library for Python

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Contributors

Languages