Merge branch 'development' into autonomous

autonomous
morpheus65535 3 years ago
commit 545fd50a69

@ -34,7 +34,7 @@ class Badges(Resource):
.where(reduce(operator.and_, movies_conditions))\
.count()
throttled_providers = len(eval(str(get_throttled_providers())))
throttled_providers = len(get_throttled_providers())
health_issues = len(get_health_issues())

@ -316,12 +316,15 @@ def reset_throttled_providers():
def get_throttled_providers():
providers = {}
if os.path.exists(os.path.join(args.config_dir, 'config', 'throttled_providers.dat')):
with open(os.path.normpath(os.path.join(args.config_dir, 'config', 'throttled_providers.dat')), 'r') as handle:
providers = handle.read()
if not providers:
try:
if os.path.exists(os.path.join(args.config_dir, 'config', 'throttled_providers.dat')):
with open(os.path.normpath(os.path.join(args.config_dir, 'config', 'throttled_providers.dat')), 'r') as \
handle:
providers = ast.literal_eval(handle.read())
except (OSError, ValueError):
providers = {}
return providers
finally:
return providers
def set_throttled_providers(data):
@ -330,11 +333,11 @@ def set_throttled_providers(data):
try:
tp = eval(str(get_throttled_providers()))
tp = get_throttled_providers()
if not isinstance(tp, dict):
raise ValueError('tp should be a dict')
except Exception:
logging.error("Invalid content in throttled_providers.dat. Resetting")
# set empty content in throttled_providers.dat
set_throttled_providers('')
tp = eval(str(get_throttled_providers()))
tp = get_throttled_providers()

@ -197,6 +197,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) + "%."
@ -388,9 +389,10 @@ def manual_search(path, profileId, providers, providers_auth, title, media_type)
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…
Cancel
Save