Pre-review audit found premature abstraction + lying docstrings. Cut what isn't used, made the rest match what's actually shipped. (1) Engine: dropped 7 cross-server dispatch wrappers that had ZERO production callers (ensure_connection / get_all_artists / get_all_album_ids / search_tracks / trigger_library_scan / is_library_scanning / get_library_stats / get_recently_added_albums). Every consumer reaches the active client directly via sync_service._get_active_media_client() or engine.client(name). Engine surface shrinks to client(name) / active_client() / active_server / is_connected() (the one wrapper that has callers — 4 dashboard status sites) / configured_clients() / reload_config(). ~150 lines deleted, 5 dead-method tests removed. (2) Contract Protocol body trimmed to match REQUIRED_METHODS exactly (is_connected, ensure_connection, get_all_artists, get_all_album_ids). The other 5 methods that were declared in the Protocol "required" section weren't actually required — Plex doesn't implement get_recently_added_albums, Jellyfin doesn't implement search_tracks, SoulSync doesn't implement most of them. Static contract now matches runtime conformance test. Optional methods moved to a KNOWN_PER_SERVER_METHODS data-only listing with audited per-server coverage notes — discoverability without false promises. (3) Engine module docstring + __init__.py docstring no longer overclaim "33+ chains collapsed" — only 4 uniform-shape chains were collapsed; ~18 server-specific chains stay explicit per the "lift what's truly shared" standard. Phrasing now matches reality. (4) types.py docstring claimed TrackInfo.from_jellyfin_dict and TrackInfo.from_navidrome_dict exist as classmethods. They don't — only from_plex_track / from_plex_playlist do. Jellyfin and Navidrome construct TrackInfo inline at their call sites today. Docstring now honest about that + flags the lift as a clean followup. (5) Engine line 95 comment "backward-compat for source-specific reaches" was misleading — there is no legacy alternative being preserved; engine.client(name) IS the canonical access pattern. Section header rewritten. Tests: 2121 pass (was 2126; -5 dead-method pin tests).
39 lines
1.7 KiB
Python
39 lines
1.7 KiB
Python
"""Media server engine — central registry-backed access to 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. Pre-refactor
|
|
web_server.py held four separate per-server globals
|
|
(``plex_client`` / ``jellyfin_client`` / ``navidrome_client`` /
|
|
``soulsync_library_client``) that every dispatch site reached
|
|
individually. This package replaces those globals with a single
|
|
engine that owns the client instances + a generic
|
|
``engine.client(name)`` accessor.
|
|
|
|
The 18-or-so ``if active_server == 'plex' / 'jellyfin' / ...``
|
|
chains in web_server.py that do server-specific work (Plex raw
|
|
playlist API vs Jellyfin / Navidrome client methods returning
|
|
different shapes) stay explicit at the call site per the "lift
|
|
what's truly shared" standard — but they reach the per-server
|
|
client through ``engine.client(name)`` rather than the legacy
|
|
globals. The four uniform-shape ``is_connected`` chains were the
|
|
only ones genuinely shared and are now ``engine.is_connected()``.
|
|
|
|
See ``docs/media-server-engine-refactor-plan.md`` for the full
|
|
phased plan.
|
|
|
|
Note: only ``MediaServerClient`` is re-exported here. The engine +
|
|
registry are NOT — importing the registry triggers eager imports
|
|
of every per-server client class, and those clients now inherit
|
|
``MediaServerClient`` (Cin-1), so re-exporting them here would
|
|
form a circular import the moment a client tried to resolve its
|
|
base class. Import them directly from their submodules:
|
|
from core.media_server.engine import MediaServerEngine
|
|
from core.media_server.registry import build_default_registry
|
|
"""
|
|
|
|
from core.media_server.contract import MediaServerClient
|
|
|
|
__all__ = [
|
|
"MediaServerClient",
|
|
]
|