Catch and logging

This commit is contained in:
Brage Skjønborg 2025-07-06 00:15:09 +02:00
parent 7f79eb1e26
commit b48c59b377
2 changed files with 34 additions and 19 deletions

View File

@ -1,4 +1,5 @@
import logging
from fuzzywuzzy import fuzz, process from fuzzywuzzy import fuzz, process
from .AlgorithmBase import AlgorithmBase, MatchResult from .AlgorithmBase import AlgorithmBase, MatchResult
from clazz.Metadata import Metadata from clazz.Metadata import Metadata
@ -10,6 +11,7 @@ class SimpleMatcher(AlgorithmBase):
best_score = -1 best_score = -1
match_results = [] match_results = []
try:
for title in self.titles: for title in self.titles:
for metadata in self.metadata: for metadata in self.metadata:
# Match against metadata title # Match against metadata title
@ -26,7 +28,12 @@ class SimpleMatcher(AlgorithmBase):
if alt_score > best_score: if alt_score > best_score:
best_score = alt_score best_score = alt_score
best_match = metadata if alt_score >= 70 else None best_match = metadata if alt_score >= 70 else None
except Exception as e:
logging.debug("Unntak: {e}")
logging.debug(f"type(title): {type(title)}, value: {title}")
logging.debug(f"type(alt_title): {type(alt_title)}, value: {alt_title}")
logging.debug(f"Metadata objekt:")
logging.debug(metadata.to_dict())
# Print match summary # Print match summary
self.print_match_summary(match_results) self.print_match_summary(match_results)

View File

@ -55,9 +55,17 @@ class UseSource:
highScore = fuzz.ratio(self.stripped(title_to_check.lower()), self.stripped(wd.result.title.lower())) highScore = fuzz.ratio(self.stripped(title_to_check.lower()), self.stripped(wd.result.title.lower()))
for alt_title in wd.result.altTitle: for alt_title in wd.result.altTitle:
try:
altScore = fuzz.ratio(self.stripped(title_to_check.lower()), self.stripped(alt_title.lower())) altScore = fuzz.ratio(self.stripped(title_to_check.lower()), self.stripped(alt_title.lower()))
if altScore > highScore: if altScore > highScore:
highScore = altScore highScore = altScore
except Exception as e:
logging.debug("Unntak: {e}")
logging.debug(f"type(title): {type(title)}, value: {title}")
logging.debug(f"type(alt_title): {type(alt_title)}, value: {alt_title}")
logging.debug(f"Metadata objekt:")
logging.debug(weightData)
givenScore = highScore * wd.weight givenScore = highScore * wd.weight
result.append(DataAndScore(wd.result, givenScore, wd.weight, title_to_check)) result.append(DataAndScore(wd.result, givenScore, wd.weight, title_to_check))