Skip to main content

Library provider base classes for the AniBridge project.

Project description

anibridge-library-base

anibridge-library-base provides base classes and utilities to implement and register media library providers for the AniBridge project.

[!IMPORTANT] This package is intended for developers building AniBridge library providers. If you're looking to use AniBridge as an end user, please refer to the AniBridge documentation.

Installation

pip install anibridge-library-base
# pip install git+https://github.com/anibridge/anibridge-library-base.git

API reference

The package exposes core base classes in anibridge.library.base and registration helpers in anibridge.library.registry.

To get more context, read the anibridge.library.base and anibridge.library.registry module docstrings.

  • LibraryProvider (base class)

    • Key methods and hooks:
      • __init__(*, config: dict | None = None) -> None: Construct a provider with optional configuration.
      • async initialize() -> None: Optional async initialization hook for I/O or authentication.
      • async clear_cache() -> None: Clear any provider caches to free memory or refresh data.
      • async close() -> None: Close the provider and release resources.
      • async get_sections() -> Sequence[LibrarySection[LibraryProviderT]]: Return available library sections for the provider.
      • async list_items(section: LibrarySection[LibraryProviderT], *, min_last_modified: datetime | None = None, require_watched: bool = False, keys: Sequence[str] | None = None) -> Sequence[LibraryMedia[LibraryProviderT]]: List media items within a section with optional filtering.
      • async parse_webhook(request: Request) -> tuple[bool, Sequence[str]]: Parse an incoming webhook and return whether it applies plus affected item keys.
      • user() -> LibraryUser | None: Return the associated user object, if any.
  • LibraryEntry (per-item user state)

    • Key methods and properties:
      • async history() -> Sequence[HistoryEntry]: Return user history events for the item (tz-aware timestamps).
      • media() -> LibraryMedia[LibraryProviderT]: Return the associated LibraryMedia object.
      • on_watching -> bool: Whether the item is currently being watched.
      • on_watchlist -> bool: Whether the item is on the user's watchlist.
      • async review() -> str | None: Return the user's review text for the item, if any.
      • section() -> LibrarySection[LibraryProviderT]: Return the parent library section for the item.
      • user_rating -> int | None: Optional user rating on a 0–100 scale.
      • view_count -> int: Total view count for the item (including children).
  • LibraryMedia (media metadata)

    • Key properties and helpers:
      • external_url -> str | None: URL to the provider's media item, if available.
      • poster_image -> str | None: Poster or cover image URL, if available.
      • ids() -> dict[str, str]: External identifier mappings for logging/debugging.
  • LibraryShow, LibrarySeason, LibraryEpisode, LibraryMovie

    • LibraryShow:
      • episodes() -> Sequence[LibraryEpisode[LibraryProviderT]]: Return child episodes.
      • seasons() -> Sequence[LibrarySeason[LibraryProviderT]]: Return child seasons.
    • LibrarySeason:
      • index: int: Season index.
      • episodes() -> Sequence[LibraryEpisode[LibraryProviderT]]: Return episodes in the season.
      • show() -> LibraryShow[LibraryProviderT]: Return the parent show.
    • LibraryEpisode:
      • index: int, season_index: int: Episode and season indices.
      • season() -> LibrarySeason[LibraryProviderT]: Return parent season.
      • show() -> LibraryShow[LibraryProviderT]: Return parent show.
  • HistoryEntry

    • library_key: str, viewed_at: datetime — records a timezone-aware view event for an item.
  • MediaKind (StrEnum)

    • High-level media kinds: MOVIE, SHOW, SEASON, EPISODE.
  • LibraryProviderRegistry and library_provider decorator

    • Registry API (see anibridge.library.registry):
      • create(namespace: str, *, config: dict | None = None) -> LibraryProvider: Instantiate a provider for namespace.
      • get(namespace: str) -> type[LibraryProvider]: Return the provider class registered under namespace.
      • namespaces() -> tuple[str, ...]: Return registered namespace identifiers.
      • register(provider_cls: type[LibraryProvider] | None = None, *, namespace: str | None = None) -> type[LibraryProvider] | Callable[[type[LP]], type[LP]]: Register a provider class or act as a decorator factory.
      • unregister(namespace: str) -> None: Remove a provider registration.
      • provider_registry: Module-level registry instance.
      • library_provider(...): Convenience decorator to register providers into the module-level registry.

Examples

You can view the following built-in provider implementations as examples of how to implement the base classes:

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

anibridge_library_base-0.2.0b3.tar.gz (6.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

anibridge_library_base-0.2.0b3-py3-none-any.whl (8.4 kB view details)

Uploaded Python 3

File details

Details for the file anibridge_library_base-0.2.0b3.tar.gz.

File metadata

  • Download URL: anibridge_library_base-0.2.0b3.tar.gz
  • Upload date:
  • Size: 6.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.10.4 {"installer":{"name":"uv","version":"0.10.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for anibridge_library_base-0.2.0b3.tar.gz
Algorithm Hash digest
SHA256 0d62a0e0b37b416fe858999f2f2713ea60b8c78469598a64adf0269f881ca777
MD5 dfd241d50395f7086edcc9114226a82a
BLAKE2b-256 1fcc5ce442cdf52cb455987629aea3e2f15c017458a369b82cdf6eb9997d2a64

See more details on using hashes here.

File details

Details for the file anibridge_library_base-0.2.0b3-py3-none-any.whl.

File metadata

  • Download URL: anibridge_library_base-0.2.0b3-py3-none-any.whl
  • Upload date:
  • Size: 8.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.10.4 {"installer":{"name":"uv","version":"0.10.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for anibridge_library_base-0.2.0b3-py3-none-any.whl
Algorithm Hash digest
SHA256 18838ad7c8e75498f0ac789d7aa52840ef07fed7668b57eacad62794dd5a8bbd
MD5 32c9a6e163ba373cc416aaf06a9bf2bd
BLAKE2b-256 3afba59c711a08afaa9e82ad811879787164f02bf967d20723a2b4dbc416f7f8

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