Stop dropping seasons Plex reports without a parentRatingKey
The first real scan logged 15 "episode has no season; skipped" warnings. They are Firefly S1 in TV Show Archive: Plex returns those episodes with grandparentRatingKey and parentIndex set and parentGuid present, but parentRatingKey null. Requiring parentRatingKey meant the entire season was silently absent from the report - exactly the kind of quiet omission a reclaim tool must not have. The season key is now synthesized from show + season number when Plex omits it, which is stable across scans. Keep marks are unaffected either way since they key on GUIDs, not rating keys. Also drops the multi_part flag from ordinary seasons. A season has one part per episode, so part_count > 1 is normal there and the badge appeared on every TV row; it now means what it says - a movie held more than once, or a season with more files than episodes. Both cases are in the fake server now, so the suite covers them. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GVbG48GAXfCZatcmX123Ra
This commit is contained in:
parent
71cfa31f09
commit
d12cbc62ee
5 changed files with 66 additions and 2 deletions
|
|
@ -119,3 +119,22 @@ def test_refuses_history_from_a_different_plex_server(db, cfg, monkeypatch):
|
|||
result = ingest.Ingest(db, cfg, media, history).run("full", "manual")
|
||||
assert result.status == "failed"
|
||||
assert "different plex server" in (result.error or "").lower()
|
||||
|
||||
|
||||
def test_episodes_without_a_parent_rating_key_still_build_a_season(scanned):
|
||||
"""Plex omits parentRatingKey on some episodes (Firefly, live). Dropping
|
||||
them silently lost a whole 15-episode season from the report."""
|
||||
season = scanned.one(
|
||||
"SELECT i.*, p.title AS show FROM media_item i "
|
||||
"JOIN media_item p ON p.id = i.parent_id "
|
||||
"WHERE i.kind='season' AND p.title='Orphan Show'")
|
||||
assert season is not None, "season was dropped for want of a parentRatingKey"
|
||||
assert season["episode_count"] == 5
|
||||
assert season["size_bytes"] == 5 * 2 * 10**9
|
||||
assert season["season_number"] == 1
|
||||
assert ":s1" in season["provider_item_id"], "expected a synthesized season key"
|
||||
|
||||
|
||||
def test_no_orphan_episode_warnings(scanned, rescan):
|
||||
r = rescan("full")
|
||||
assert not [w for w in (r.warnings or []) if "no season" in w]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue