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
|
|
@ -197,6 +197,17 @@ class PlexProvider:
|
|||
))
|
||||
|
||||
kind = "movie" if library.kind == "movie" else "episode"
|
||||
|
||||
# Plex sometimes returns an episode with no parentRatingKey even though
|
||||
# it knows the show and the season number (seen on Firefly in TV Show
|
||||
# Archive: 15 episodes, parentGuid present, parentRatingKey null).
|
||||
# Without a season id the whole season used to be dropped from the
|
||||
# report, so synthesize a stable one from show + season number.
|
||||
season_id = row.get("parentRatingKey")
|
||||
if season_id is None and row.get("grandparentRatingKey") is not None \
|
||||
and row.get("parentIndex") is not None:
|
||||
season_id = "%s:s%s" % (row["grandparentRatingKey"], row["parentIndex"])
|
||||
|
||||
return Item(
|
||||
provider_item_id=str(rk),
|
||||
kind=kind,
|
||||
|
|
@ -215,7 +226,7 @@ class PlexProvider:
|
|||
parts=parts,
|
||||
show_id=str(row["grandparentRatingKey"]) if row.get("grandparentRatingKey") is not None else None,
|
||||
show_title=row.get("grandparentTitle"),
|
||||
season_id=str(row["parentRatingKey"]) if row.get("parentRatingKey") is not None else None,
|
||||
season_id=str(season_id) if season_id is not None else None,
|
||||
season_number=_opt_int(row.get("parentIndex")),
|
||||
episode_number=_opt_int(row.get("index")),
|
||||
)
|
||||
|
|
|
|||
|
|
@ -200,7 +200,11 @@ class Query:
|
|||
flags.append("duplicate")
|
||||
if (d.get("provider_view_count") or 0) > 0 and not d.get("watch_count"):
|
||||
flags.append("history_gap")
|
||||
if (d.get("part_count") or 0) > 1:
|
||||
# A season has one part per episode, so part_count > 1 is normal there;
|
||||
# only flag genuinely extra files (a movie held twice, or a split episode).
|
||||
parts = d.get("part_count") or 0
|
||||
if (d["kind"] == "movie" and parts > 1) or \
|
||||
(d["kind"] == "season" and parts > (d.get("episode_count") or 0)):
|
||||
flags.append("multi_part")
|
||||
|
||||
return {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue