From cbd70bd6f3438cdb2af4b1cf540653636a876007 Mon Sep 17 00:00:00 2001 From: Juan David Bermudez Celedon Date: Thu, 26 Feb 2026 10:37:29 -0500 Subject: [PATCH] Fix scoring rules keyword matching (#473) Fixs for #460 ## Summary by CodeRabbit ## Release Notes * **Improvements** * Refined keyword matching in indexer queries with case-insensitive, word-boundary-aware search for more accurate results. * **Bug Fixes** * Corrected torrent URL redirect resolution logic. --- media_manager/indexer/utils.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/media_manager/indexer/utils.py b/media_manager/indexer/utils.py index 5d17e30..842cbcd 100644 --- a/media_manager/indexer/utils.py +++ b/media_manager/indexer/utils.py @@ -1,4 +1,5 @@ import logging +import re from urllib.parse import urljoin import requests @@ -23,7 +24,7 @@ def evaluate_indexer_query_result( log.debug(f"Applying rule {rule.name} to {query_result.title}") if ( any( - keyword.lower() in query_result.title.lower() + re.search(rf"\b{re.escape(keyword)}\b", query_result.title, re.IGNORECASE) for keyword in rule.keywords ) and not rule.negate @@ -34,7 +35,7 @@ def evaluate_indexer_query_result( query_result.score += rule.score_modifier elif ( not any( - keyword.lower() in query_result.title.lower() + re.search(rf"\b{re.escape(keyword)}\b", query_result.title, re.IGNORECASE) for keyword in rule.keywords ) and rule.negate @@ -155,5 +156,3 @@ def follow_redirects_to_final_torrent_url( ) msg = "An error occurred during the request" raise RuntimeError(msg) from e - - return current_url