Stop trusting Plex's Date Added on its own
Jess spotted that dates looked like file dates rather than library-add dates. He is right, and MediaShelf was not the culprit: it reproduces Plex's addedAt exactly (verified 500/500 identical to the second). Plex's own field is what follows the file — replace or re-encode one and Date Added resets while the item, its ratingKey and its watch history all survive. Measured on the live library, comparing addedAt against lastViewedAt where both exist: 55 of 509 movies (10.8%) and 306 of 1,393 TV Show Archive items (22.0%) were watched BEFORE they were "added" — 19% overall. 2001: A Space Odyssey reports added 2026-07-31, last watched 2017-08-26. That is not cosmetic. pre_history is derived from added_at, so an old item whose file was replaced looks post-coverage and gets promoted into the CONFIDENT reclaim pool, which is the one pool meant to be trustworthy. A completed play proves the item already existed, so added_at is now MIN(provider_added_at, first_watched_at). Plex's raw value is kept in provider_added_at, added_at_source records which applied, and the item drawer explains the substitution instead of quietly disagreeing with Plex. Unwatched items keep Plex's value since nothing contradicts it. first_seen_at is also recorded now and is authoritative for anything added from here on. Plex's API has no better field; the true insert time is only in Plex's own metadata_items.created_at on Loki. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GVbG48GAXfCZatcmX123Ra
This commit is contained in:
parent
d12cbc62ee
commit
e819548ff2
9 changed files with 234 additions and 15 deletions
|
|
@ -65,6 +65,7 @@ BASE_COLUMNS = """
|
|||
i.last_watched_at, i.last_touched_at, i.first_watched_at,
|
||||
i.distinct_watcher_count, i.pre_history, i.kept, i.kept_via, i.kept_mark_id,
|
||||
i.provider_view_count, i.status, i.parent_id, i.season_number,
|
||||
i.provider_added_at, i.added_at_source, i.first_seen_at,
|
||||
parent.title AS show_title
|
||||
"""
|
||||
|
||||
|
|
@ -200,6 +201,8 @@ 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("added_at_source") == "first_watch":
|
||||
flags.append("added_corrected")
|
||||
# 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
|
||||
|
|
@ -218,6 +221,9 @@ class Query:
|
|||
"library": {"id": d["library_id"], "title": d["library_title"]},
|
||||
"size_bytes": d.get("size_bytes") or 0,
|
||||
"added_at": d.get("added_at"),
|
||||
"provider_added_at": d.get("provider_added_at"),
|
||||
"added_at_source": d.get("added_at_source"),
|
||||
"first_seen_at": d.get("first_seen_at"),
|
||||
"last_watched_at": d.get("last_watched_at"),
|
||||
"last_touched_at": d.get("last_touched_at"),
|
||||
"watch_count": d.get("watch_count") or 0,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue