mirror of
https://github.com/maxdorninger/MediaManager.git
synced 2026-04-17 15:43:28 +02:00
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:
committed by
GitHub
parent
d8405fd903
commit
cbd70bd6f3
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user