mirror of
https://github.com/morpheus65535/bazarr
synced 2024-12-27 18:17:46 +00:00
Fix hash score in manual search
This commit is contained in:
parent
204a1c3f31
commit
2cde2686fc
2 changed files with 14 additions and 4 deletions
|
@ -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')
|
||||
|
|
|
@ -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):
|
||||
|
|
Loading…
Reference in a new issue