`MediaServerEngine` reads the active server from config + dispatches to the corresponding registered client. Per-server reaches still work through `engine.client(name)`. Required-method dispatch (is_connected, ensure_connection, get_all_artists, get_all_album_ids) returns safe defaults when the active client failed to initialize OR when the method raises. Optional-method dispatch (search_tracks, trigger_library_scan, is_library_scanning, get_library_stats, get_recently_added_albums) checks hasattr first — SoulSync standalone has no trigger_library_scan or get_library_stats, engine no-ops with appropriate defaults instead of forcing every client to declare stub methods. 10 new engine tests pin: active-server resolution, required dispatch routing, exception safety, missing-optional-method fallback shape. Suite still green (1951 passed). Engine isn't on any production code path yet — Phase C migrates the 33 web_server.py dispatch sites to call engine.method() instead of hand-branching by active_server name.
29 lines
1.1 KiB
Python
29 lines
1.1 KiB
Python
"""Media server engine — central dispatch for the per-server clients
|
|
(Plex, Jellyfin, Navidrome, SoulSync standalone).
|
|
|
|
Companion to the download engine refactor — same architectural
|
|
shape applied to the read-side of the library. The orchestrator
|
|
historically had 33+ ``if active_server == 'plex' / 'jellyfin' /
|
|
...`` dispatch sites in web_server.py. This package replaces those
|
|
with a single ``MediaServerEngine.method()`` call per operation.
|
|
|
|
Per-server clients keep their protocol-specific work (Plex's
|
|
PlexAPI SDK, Jellyfin's REST endpoints, Navidrome's OpenSubsonic
|
|
API, SoulSync's filesystem walk). The engine just routes by
|
|
``active_server`` config + provides a uniform shape for the calls
|
|
``web_server.py`` makes generically.
|
|
|
|
See ``docs/media-server-engine-refactor-plan.md`` for the full
|
|
phased plan.
|
|
"""
|
|
|
|
from core.media_server.contract import MediaServerClient
|
|
from core.media_server.engine import MediaServerEngine
|
|
from core.media_server.registry import MediaServerRegistry, build_default_registry
|
|
|
|
__all__ = [
|
|
"MediaServerClient",
|
|
"MediaServerEngine",
|
|
"MediaServerRegistry",
|
|
"build_default_registry",
|
|
]
|