diff --git a/core/automation/handlers/video_auto_wishlist_airing.py b/core/automation/handlers/video_auto_wishlist_airing.py index 7477342a..33c98af0 100644 --- a/core/automation/handlers/video_auto_wishlist_airing.py +++ b/core/automation/handlers/video_auto_wishlist_airing.py @@ -28,14 +28,22 @@ def _default_fetch_airing(today: str) -> List[Dict[str, Any]]: def _default_add_episodes(show_tmdb_id: Any, show_title: Any, episodes: List[Dict[str, Any]], - library_id: Any = None) -> int: + library_id: Any = None, poster_url: Any = None) -> int: from api.video import get_video_db from core.video.sources import resolve_video_server return get_video_db().add_episodes_to_wishlist( - show_tmdb_id, show_title, episodes, library_id=library_id, + show_tmdb_id, show_title, episodes, poster_url=poster_url, library_id=library_id, server_source=resolve_video_server()) +def _show_poster_url(library_id: Any) -> Optional[str]: + """The SAME poster a manual add stores for a library show — the show poster proxy + path the wishlist orb renders directly. Mirrors the get-modal's + pUrl = '/api/video/poster/show/'. Without it the orb falls back to the + show's initials, reading as 'not matched'.""" + return ('/api/video/poster/show/%s' % library_id) if library_id is not None else None + + def _default_season_meta(tmdb_id: Any, season_number: Any): """The SAME TMDB season fetch the show modal uses for a manual add — so auto-added episodes carry identical stills / overviews / season posters, not the patchy values @@ -114,7 +122,8 @@ def auto_video_add_airing_episodes( added = 0 for (tid, title), grp in by_show.items(): - added += int(add_episodes(tid, title, grp['eps'], grp['library_id']) or 0) + added += int(add_episodes(tid, title, grp['eps'], grp['library_id'], + _show_poster_url(grp['library_id'])) or 0) shows = len(by_show) deps.update_progress( diff --git a/tests/test_video_auto_wishlist_airing.py b/tests/test_video_auto_wishlist_airing.py index 341d5c66..b945f5a1 100644 --- a/tests/test_video_auto_wishlist_airing.py +++ b/tests/test_video_auto_wishlist_airing.py @@ -29,8 +29,8 @@ def test_adds_unowned_airings_grouped_by_show(): ] added = [] - def add(tid, title, eps, library_id=None): - added.append((tid, title, len(eps), library_id)) + def add(tid, title, eps, library_id=None, poster_url=None): + added.append((tid, title, len(eps), library_id, poster_url)) return len(eps) res = auto_video_add_airing_episodes( @@ -41,8 +41,10 @@ def test_adds_unowned_airings_grouped_by_show(): assert res["status"] == "completed" assert res["episodes_added"] == 3 # 2 of Widows Bay + 1 of Another Show assert res["shows"] == 2 - # the show's library_id (show_id) is carried so the wishlist can match the show - assert (1, "Widows Bay", 2, 100) in added and (2, "Another Show", 1, 200) in added + # the show's library_id (show_id) + poster proxy are carried so the wishlist + # matches the show and the orb renders the show poster (like a manual add) + assert (1, "Widows Bay", 2, 100, "/api/video/poster/show/100") in added + assert (2, "Another Show", 1, 200, "/api/video/poster/show/200") in added def test_uses_tmdb_season_metadata_like_a_manual_add(): @@ -60,7 +62,7 @@ def test_uses_tmdb_season_metadata_like_a_manual_add(): captured = {} - def add(tid, title, eps, library_id=None): + def add(tid, title, eps, library_id=None, poster_url=None): captured["eps"] = eps return len(eps) @@ -79,7 +81,7 @@ def test_falls_back_to_db_values_when_tmdb_unavailable(): "has_file": False, "overview": "db synopsis", "still_url": "/library/metadata/9/thumb/1"}] captured = {} - def add(tid, title, eps, library_id=None): + def add(tid, title, eps, library_id=None, poster_url=None): captured["eps"] = eps return len(eps)