video: include season id in show_detail (fix /poster/season/undefined 404)

show_detail's season payload omitted the season id, so the frontend built
/api/video/poster/season/undefined and 404'd — season posters never showed even
once cached. Add the id; harden seasonArt to fall back to the show poster if id
is ever missing. Test pins that seasons carry an int id.
This commit is contained in:
BoulderBadgeDad 2026-06-14 21:02:35 -07:00
parent 986059626f
commit 8002f93220
3 changed files with 3 additions and 1 deletions

View file

@ -848,6 +848,7 @@ class VideoDatabase:
owned = sum(1 for e in ep_list if e["owned"])
meta = season_meta.get(num)
out_seasons.append({
"id": meta["id"] if meta else None, # needed for the season poster proxy
"season_number": num,
"title": (meta["title"] if meta else None) or (
"Specials" if num == 0 else "Season %d" % num),

View file

@ -265,6 +265,7 @@ def test_show_detail_builds_season_episode_tree_with_rollups(db):
assert d["seasons"][0]["title"] == "Specials"
s1 = d["seasons"][1]
assert s1["title"] == "Season One"
assert isinstance(s1["id"], int) # season id present for the poster proxy
assert (s1["episode_total"], s1["episode_owned"]) == (2, 1)
assert s1["episodes"][0]["owned"] is True and s1["episodes"][1]["owned"] is False

View file

@ -58,7 +58,7 @@
return null;
}
function seasonArt(s) {
return s.has_poster ? '/api/video/poster/season/' + s.id
return (s.has_poster && s.id != null) ? '/api/video/poster/season/' + s.id
: (data && data.has_poster ? '/api/video/poster/show/' + data.id : '');
}
function pct(s) { return s.episode_total ? Math.round(s.episode_owned / s.episode_total * 100) : 0; }