From 7b933ff97ac9e47215815d0692f4579b38882b49 Mon Sep 17 00:00:00 2001 From: Broque Thomas <26755000+Nezreka@users.noreply.github.com> Date: Sun, 8 Mar 2026 19:13:09 -0700 Subject: [PATCH] Fix Plex album completion false positives from leafCount reflecting partial ownership --- database/music_database.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/database/music_database.py b/database/music_database.py index f8d00e3b..9113fbaa 100644 --- a/database/music_database.py +++ b/database/music_database.py @@ -3515,8 +3515,12 @@ class MusicDatabase: # count so edition differences don't make a complete album appear incomplete. # e.g. user has standard edition (12 tracks, all present) but Spotify returns # deluxe edition count (20) — should show as complete, not 12/20. - if expected_track_count is not None and stored_track_count > 0 and owned_tracks >= stored_track_count: - # Album is complete by its own metadata — don't inflate expected with a different edition's count + if (expected_track_count is not None and stored_track_count > 0 + and owned_tracks >= stored_track_count + and stored_track_count >= expected_track_count * 0.6): + # Album is complete by its own metadata — don't inflate expected with a different edition's count. + # Guard: stored count must be >=60% of expected to look like a plausible edition variant + # (standard 12 vs deluxe 20 = 60%), not just Plex's leafCount reflecting partial ownership. expected_tracks = stored_track_count elif expected_track_count is not None: expected_tracks = expected_track_count