Library Provider API
AniBridge library provider base package.
HistoryEntry
dataclass
User history event for a library item.
Source code in .venv/lib/python3.14/site-packages/anibridge/library/base.py
LibraryEntity
dataclass
Bases: ABC
Base class for library entities.
Source code in .venv/lib/python3.14/site-packages/anibridge/library/base.py
key
property
Return the unique key for this entity.
media_kind
property
Return the high-level media kind of this entity.
title
property
Return the entity title.
__eq__(other)
Compare entities by provider namespace and key.
Source code in .venv/lib/python3.14/site-packages/anibridge/library/base.py
__hash__()
Compute a hash based on provider namespace, class name, and key.
__repr__()
LibraryEntry
dataclass
Bases: LibraryEntity[ProviderT], ABC
Base class for library entries.
Source code in .venv/lib/python3.14/site-packages/anibridge/library/base.py
key
property
Return the unique key for this entity.
media_kind
property
Return the high-level media kind of this entity.
on_watching
abstractmethod
property
Whether the item is on the user's current watching list.
on_watchlist
abstractmethod
property
Whether the item is on the user's watchlist.
review
abstractmethod
async
property
Return the user's review text for this item, if any.
title
property
Return the entity title.
user_rating
abstractmethod
property
User rating on a 0-100 scale, or None if not rated.
view_count
abstractmethod
property
Total view count for the item (including children).
__eq__(other)
Compare entities by provider namespace and key.
Source code in .venv/lib/python3.14/site-packages/anibridge/library/base.py
__hash__()
Compute a hash based on provider namespace, class name, and key.
__repr__()
history()
abstractmethod
async
Return user history entries for this media item (tz-aware timestamps).
mapping_descriptors()
abstractmethod
Return possible mapping descriptors for the media item.
The returned descriptors refer to providers in the mapping database. They are not related to the library provider of this item (although, they might match).
Source code in .venv/lib/python3.14/site-packages/anibridge/library/base.py
media()
abstractmethod
provider()
section()
abstractmethod
LibraryEpisode
dataclass
Bases: LibraryEntry[LibraryProviderT], ABC
Episode item within a season/show.
Source code in .venv/lib/python3.14/site-packages/anibridge/library/base.py
key
property
Return the unique key for this entity.
media_kind
property
Return the high-level media kind of this entity.
on_watching
abstractmethod
property
Whether the item is on the user's current watching list.
on_watchlist
abstractmethod
property
Whether the item is on the user's watchlist.
review
abstractmethod
async
property
Return the user's review text for this item, if any.
title
property
Return the entity title.
user_rating
abstractmethod
property
User rating on a 0-100 scale, or None if not rated.
view_count
abstractmethod
property
Total view count for the item (including children).
__eq__(other)
Compare entities by provider namespace and key.
Source code in .venv/lib/python3.14/site-packages/anibridge/library/base.py
__hash__()
Compute a hash based on provider namespace, class name, and key.
__repr__()
Short representation including show title, season and episode indexes.
Source code in .venv/lib/python3.14/site-packages/anibridge/library/base.py
history()
abstractmethod
async
Return user history entries for this media item (tz-aware timestamps).
mapping_descriptors()
abstractmethod
Return possible mapping descriptors for the media item.
The returned descriptors refer to providers in the mapping database. They are not related to the library provider of this item (although, they might match).
Source code in .venv/lib/python3.14/site-packages/anibridge/library/base.py
media()
abstractmethod
provider()
season()
abstractmethod
Get the parent season of the episode.
Returns:
| Name | Type | Description |
|---|---|---|
LibrarySeason |
LibrarySeason[LibraryProviderT]
|
The parent season. |
section()
abstractmethod
show()
abstractmethod
Get the parent show of the episode.
Returns:
| Name | Type | Description |
|---|---|---|
LibraryShow |
LibraryShow[LibraryProviderT]
|
The parent show. |
LibraryMedia
dataclass
Bases: LibraryEntity[LibraryProviderT], ABC
Base class for library media items.
Implementations should provide concrete behaviour for the abstract properties and methods below.
Source code in .venv/lib/python3.14/site-packages/anibridge/library/base.py
external_url
property
URL to the provider's media item, if available.
key
property
Return the unique key for this entity.
media_kind
property
Return the high-level media kind of this entity.
poster_image
property
Primary poster or cover image URL, if available.
title
property
Return the entity title.
__eq__(other)
Compare entities by provider namespace and key.
Source code in .venv/lib/python3.14/site-packages/anibridge/library/base.py
__hash__()
Compute a hash based on provider namespace, class name, and key.
__repr__()
LibraryMovie
dataclass
Bases: LibraryEntry[LibraryProviderT], ABC
Movie item in a media library.
Source code in .venv/lib/python3.14/site-packages/anibridge/library/base.py
key
property
Return the unique key for this entity.
media_kind
property
Return the high-level media kind of this entity.
on_watching
abstractmethod
property
Whether the item is on the user's current watching list.
on_watchlist
abstractmethod
property
Whether the item is on the user's watchlist.
review
abstractmethod
async
property
Return the user's review text for this item, if any.
title
property
Return the entity title.
user_rating
abstractmethod
property
User rating on a 0-100 scale, or None if not rated.
view_count
abstractmethod
property
Total view count for the item (including children).
__eq__(other)
Compare entities by provider namespace and key.
Source code in .venv/lib/python3.14/site-packages/anibridge/library/base.py
__hash__()
Compute a hash based on provider namespace, class name, and key.
__repr__()
history()
abstractmethod
async
Return user history entries for this media item (tz-aware timestamps).
mapping_descriptors()
abstractmethod
Return possible mapping descriptors for the media item.
The returned descriptors refer to providers in the mapping database. They are not related to the library provider of this item (although, they might match).
Source code in .venv/lib/python3.14/site-packages/anibridge/library/base.py
media()
abstractmethod
provider()
section()
abstractmethod
LibraryProvider
Bases: ABC
Abstract base provider that exposes a user media library.
Source code in .venv/lib/python3.14/site-packages/anibridge/library/base.py
280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 | |
__init__(*, config=None)
Initialize the provider with optional configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
dict | None
|
Any configuration options that were detected with the provider's namespace as a prefix. |
None
|
Source code in .venv/lib/python3.14/site-packages/anibridge/library/base.py
clear_cache()
async
Clear any cached data held by the provider.
For more efficient implementations, it is a good idea to cache data fetched from the provider to minimize network requests. AniBridge uses this method occasionally to clear such caches.
Source code in .venv/lib/python3.14/site-packages/anibridge/library/base.py
close()
async
get_sections()
abstractmethod
async
Return available library sections for the provider.
Returns:
| Type | Description |
|---|---|
Sequence[LibrarySection[LibraryProviderT]]
|
Sequence[LibrarySection[LibraryProviderT]]: The available library sections. |
Source code in .venv/lib/python3.14/site-packages/anibridge/library/base.py
initialize()
async
Asynchronous initialization hook.
Put any async logic that should be run after construction here.
list_items(section, *, min_last_modified=None, require_watched=False, keys=None)
abstractmethod
async
List items in a library section with optional filtering.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
section
|
LibrarySection[LibraryProviderT]
|
The library section to list items from. |
required |
min_last_modified
|
datetime | None
|
If provided, only include items modified after this timezone-aware timestamp. |
None
|
require_watched
|
bool
|
If True, only include items marked as watched. |
False
|
keys
|
Sequence[str] | None
|
If provided, only include items whose keys are in this sequence. |
None
|
Returns:
| Type | Description |
|---|---|
Sequence[LibraryEntry[LibraryProviderT]]
|
Sequence[LibraryEntry[LibraryProviderT]]: The list of library items. |
Source code in .venv/lib/python3.14/site-packages/anibridge/library/base.py
parse_webhook(request)
async
Parse an incoming webhook and return the affected item keys.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request
|
Request
|
The incoming HTTP request. |
required |
Returns:
| Type | Description |
|---|---|
tuple[bool, Sequence[str]]
|
tuple[bool, Sequence[str]]: A tuple where the first element indicates whether the webhook applies to the current provider, and the second element is a sequence of affected item keys. |
Source code in .venv/lib/python3.14/site-packages/anibridge/library/base.py
user()
abstractmethod
Return the associated user object, if any.
Returns:
| Type | Description |
|---|---|
LibraryUser | None
|
LibraryUser | None: The associated user object, if any. |
LibraryProviderRegistry
Registry for LibraryProvider implementations.
Source code in .venv/lib/python3.14/site-packages/anibridge/library/registry.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 | |
__contains__(namespace)
Check if a provider is registered under namespace.
__init__()
__iter__()
clear()
create(namespace, *, config=None)
Instantiate the provider registered under namespace.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
namespace
|
str
|
The namespace identifier to create. |
required |
config
|
dict | None
|
Optional configuration dictionary to pass to the provider constructor. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
LibraryProvider |
LibraryProvider
|
An instance of the registered provider. |
Source code in .venv/lib/python3.14/site-packages/anibridge/library/registry.py
get(namespace)
Return the provider class registered under namespace.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
namespace
|
str
|
The namespace identifier to look up. |
required |
Returns:
| Type | Description |
|---|---|
type[LibraryProvider]
|
type[LibraryProvider]: The registered provider class. |
Source code in .venv/lib/python3.14/site-packages/anibridge/library/registry.py
namespaces()
register(provider_cls=None, *, namespace=None)
Register a provider class, optionally used as a decorator.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
provider_cls
|
type[LP] | None
|
The provider class to register. If |
None
|
namespace
|
str | None
|
Explicit namespace override. Defaults to the class'
|
None
|
Returns:
| Type | Description |
|---|---|
type[LP] | Callable[[type[LP]], type[LP]]
|
type[LP] | Callable[[type[LP]], type[LP]]: The registered provider class, or a decorator that registers the class. |
Source code in .venv/lib/python3.14/site-packages/anibridge/library/registry.py
unregister(namespace)
Remove a provider registration if it exists.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
namespace
|
str
|
The namespace identifier to unregister. |
required |
Source code in .venv/lib/python3.14/site-packages/anibridge/library/registry.py
LibrarySeason
dataclass
Bases: LibraryEntry[LibraryProviderT], ABC
Season container within a show.
Source code in .venv/lib/python3.14/site-packages/anibridge/library/base.py
key
property
Return the unique key for this entity.
media_kind
property
Return the high-level media kind of this entity.
on_watching
abstractmethod
property
Whether the item is on the user's current watching list.
on_watchlist
abstractmethod
property
Whether the item is on the user's watchlist.
review
abstractmethod
async
property
Return the user's review text for this item, if any.
title
property
Return the entity title.
user_rating
abstractmethod
property
User rating on a 0-100 scale, or None if not rated.
view_count
abstractmethod
property
Total view count for the item (including children).
__eq__(other)
Compare entities by provider namespace and key.
Source code in .venv/lib/python3.14/site-packages/anibridge/library/base.py
__hash__()
Compute a hash based on provider namespace, class name, and key.
__repr__()
Short representation including show title and season index.
episodes()
abstractmethod
Get child episodes belonging to the season.
Returns:
| Type | Description |
|---|---|
Sequence[LibraryEpisode[LibraryProviderT]]
|
Sequence[LibraryEpisode]: Child episodes. |
history()
abstractmethod
async
Return user history entries for this media item (tz-aware timestamps).
mapping_descriptors()
abstractmethod
Return possible mapping descriptors for the media item.
The returned descriptors refer to providers in the mapping database. They are not related to the library provider of this item (although, they might match).
Source code in .venv/lib/python3.14/site-packages/anibridge/library/base.py
media()
abstractmethod
provider()
section()
abstractmethod
show()
abstractmethod
Get the parent show of the season.
Returns:
| Name | Type | Description |
|---|---|---|
LibraryShow |
LibraryShow[LibraryProviderT]
|
The parent show. |
LibrarySection
dataclass
Bases: LibraryEntity[LibraryProviderT], ABC
Represents a logical collection/section within the media library.
Source code in .venv/lib/python3.14/site-packages/anibridge/library/base.py
key
property
Return the unique key for this entity.
media_kind
property
Return the high-level media kind of this entity.
title
property
Return the entity title.
__eq__(other)
Compare entities by provider namespace and key.
Source code in .venv/lib/python3.14/site-packages/anibridge/library/base.py
__hash__()
Compute a hash based on provider namespace, class name, and key.
__repr__()
LibraryShow
dataclass
Bases: LibraryEntry[LibraryProviderT], ABC
Episodic show/series in a media library.
Source code in .venv/lib/python3.14/site-packages/anibridge/library/base.py
key
property
Return the unique key for this entity.
media_kind
property
Return the high-level media kind of this entity.
on_watching
abstractmethod
property
Whether the item is on the user's current watching list.
on_watchlist
abstractmethod
property
Whether the item is on the user's watchlist.
review
abstractmethod
async
property
Return the user's review text for this item, if any.
title
property
Return the entity title.
user_rating
abstractmethod
property
User rating on a 0-100 scale, or None if not rated.
view_count
abstractmethod
property
Total view count for the item (including children).
__eq__(other)
Compare entities by provider namespace and key.
Source code in .venv/lib/python3.14/site-packages/anibridge/library/base.py
__hash__()
Compute a hash based on provider namespace, class name, and key.
__repr__()
episodes()
abstractmethod
Get child episodes belonging to the show.
Returns:
| Type | Description |
|---|---|
Sequence[LibraryEpisode[LibraryProviderT]]
|
Sequence[LibraryEpisode]: Child episodes. |
history()
abstractmethod
async
Return user history entries for this media item (tz-aware timestamps).
mapping_descriptors()
abstractmethod
Return possible mapping descriptors for the media item.
The returned descriptors refer to providers in the mapping database. They are not related to the library provider of this item (although, they might match).
Source code in .venv/lib/python3.14/site-packages/anibridge/library/base.py
media()
abstractmethod
provider()
seasons()
abstractmethod
Get child seasons belonging to the show.
Returns:
| Type | Description |
|---|---|
Sequence[LibrarySeason[LibraryProviderT]]
|
Sequence[LibrarySeason]: Child seasons. |
section()
abstractmethod
LibraryUser
dataclass
User information for a library provider.
Source code in .venv/lib/python3.14/site-packages/anibridge/library/base.py
MediaKind
Bases: StrEnum
Supported high-level media kinds within a library provider.
Source code in .venv/lib/python3.14/site-packages/anibridge/library/base.py
library_provider(cls=None, *, namespace=None, registry=None)
Class decorator that registers LibraryProvider implementations.
This helper lets third-party providers register themselves declaratively:
```
from anibridge.library import library_provider
@library_provider(namespace="plex")
class PlexLibraryProvider:
NAMESPACE = "plex"
...
```
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cls
|
type[LP] | None
|
The provider class to register. If |
None
|
namespace
|
str | None
|
Explicit namespace override. Defaults to the class'
|
None
|
registry
|
LibraryProviderRegistry | None
|
Alternate registry to insert into. Defaults to the module-level one. |
None
|
Returns:
| Type | Description |
|---|---|
type[LP] | Callable[[type[LP]], type[LP]]
|
type[LP] | Callable[[type[LP]], type[LP]]: The registered provider class, or a decorator that registers the class. |