From 2cde2686fc68a9e9c2d01f3c8a9858bffc5bd225 Mon Sep 17 00:00:00 2001 From: Vitiko Date: Sun, 5 Dec 2021 00:49:50 -0400 Subject: [PATCH] Fix hash score in manual search --- bazarr/get_subtitle.py | 4 +++- bazarr/score.py | 14 +++++++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/bazarr/get_subtitle.py b/bazarr/get_subtitle.py index 265aa24b3..8e5d35db9 100644 --- a/bazarr/get_subtitle.py +++ b/bazarr/get_subtitle.py @@ -216,6 +216,7 @@ def download_subtitle(path, language, audio_language, hi, forced, providers, pro action = "upgraded" else: action = "downloaded" + percent_score = round(subtitle.score * 100 / max_score, 2) message = downloaded_language + modifier_string + " subtitles " + action + " from " + \ downloaded_provider + " with a score of " + str(percent_score) + "%." @@ -417,9 +418,10 @@ def manual_search(path, profileId, providers, providers_auth, sceneName, title, score, score_without_hash = compute_score(matches, s, video, hearing_impaired=initial_hi, score_obj=handler) if 'hash' not in matches: not_matched = scores - matches + s.score = score_without_hash else: + s.score = score not_matched = set() - s.score = score_without_hash if s.hearing_impaired == initial_hi: matches.add('hearing_impaired') diff --git a/bazarr/score.py b/bazarr/score.py index 09b568a30..612e63df7 100644 --- a/bazarr/score.py +++ b/bazarr/score.py @@ -146,6 +146,7 @@ class Score: def __init__(self, load_profiles=False, **kwargs): self.data = self.defaults.copy() self.data.update(**kwargs) + self.data["hash"] = self._hash_score() self._profiles = [] self._profiles_loaded = False @@ -205,9 +206,16 @@ class Score: @property def max_score(self): return ( - sum(val for val in self.scores.values() if val > 0) - + sum(item.score for item in self._profiles if item.score > 0) - - self.data["hash"] + self.data["hash"] + + self.data["hearing_impaired"] + + sum(item.score for item in self._profiles if item.score) + ) + + def _hash_score(self): + return sum( + val + for key, val in self.data.items() + if key not in ("hash", "hearing_impaired") ) def __str__(self):