From 45583bd6f5d8e973fb036c07d44d5163b8198030 Mon Sep 17 00:00:00 2001 From: Justin Oro Date: Mon, 7 Sep 2026 08:16:46 -0700 Subject: [PATCH] Strip Rifftrax/channel tags and trust unique fuzzy match candidates --- plex-library-tool.py | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/plex-library-tool.py b/plex-library-tool.py index b933aa5..22c9610 100755 --- a/plex-library-tool.py +++ b/plex-library-tool.py @@ -903,21 +903,20 @@ def fuzzy_title_match(media_type, results, query, year): return None query_norm = clean_and_squeeze(query).lower() - best = None - best_ratio = 0.0 + year_matches = [r for r in results if result_year(media_type, r) == year] + if not year_matches: + return None - for r in results: - if result_year(media_type, r) != year: - continue + def title_similarity(r): title_norm = clean_and_squeeze(result_title(media_type, r) or "").lower() if not title_norm: - continue - ratio = difflib.SequenceMatcher(None, query_norm, title_norm).ratio() - if ratio > best_ratio: - best_ratio = ratio - best = r + return 0.0 + return difflib.SequenceMatcher(None, query_norm, title_norm).ratio() - if best is not None and best_ratio >= FUZZY_TITLE_MATCH_THRESHOLD: + best = max(year_matches, key=title_similarity) + best_ratio = title_similarity(best) + threshold = YEAR_MATCH_MIN_SIMILARITY if len(year_matches) == 1 else FUZZY_TITLE_MATCH_THRESHOLD + if best_ratio >= threshold: return best, best_ratio return None @@ -991,7 +990,7 @@ JUNK_TOKENS = { "bluray", "blueray", "bdrip", "brrip", "bdremux", "remux", "webrip", "webdl", "web", "dl", "hdtv", "hdrip", "dvdrip", "dvd", "hevc", "x264", "x265", "h264", "h265", "avc", "xvid", "divx", - "aac", "ac3", "eac3", "dts", "atmos", "ddp", "dd", + "aac", "ac3", "eac3", "dts", "atmos", "ddp", "dd", "rifftrax", "proper", "repack", "extended", "unrated", "uncut", "explicit", "ultimate", "director", "directors", "cut", "internal", "limited", "theatrical", "multi", "dual", "audio", "hdr", "sdr", "4k", "uhd", "10bit", "8bit", "hi10p", "hi444pp", @@ -1073,6 +1072,7 @@ RELEASE_GROUP_SUFFIX_PATTERN = re.compile( ) AUDIO_CHANNELS_PATTERN = re.compile(r'(?