Fix scoring rules keyword matching (#473)

Fixs for #460 

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## 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.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
Juan David Bermudez Celedon
2026-02-26 10:37:29 -05:00
committed by GitHub
parent d8405fd903
commit cbd70bd6f3

View File

@@ -1,4 +1,5 @@
import logging import logging
import re
from urllib.parse import urljoin from urllib.parse import urljoin
import requests import requests
@@ -23,7 +24,7 @@ def evaluate_indexer_query_result(
log.debug(f"Applying rule {rule.name} to {query_result.title}") log.debug(f"Applying rule {rule.name} to {query_result.title}")
if ( if (
any( 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 for keyword in rule.keywords
) )
and not rule.negate and not rule.negate
@@ -34,7 +35,7 @@ def evaluate_indexer_query_result(
query_result.score += rule.score_modifier query_result.score += rule.score_modifier
elif ( elif (
not any( 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 for keyword in rule.keywords
) )
and rule.negate and rule.negate
@@ -155,5 +156,3 @@ def follow_redirects_to_final_torrent_url(
) )
msg = "An error occurred during the request" msg = "An error occurred during the request"
raise RuntimeError(msg) from e raise RuntimeError(msg) from e
return current_url