Fixed issue where subtitles would get upgraded even if not required anymore by shows languages profile. #2174

pull/2131/head
morpheus65535 2 years ago
parent 2511c310f1
commit d4262e530a

@ -9,7 +9,7 @@ from functools import reduce
from app.config import settings from app.config import settings
from app.database import get_exclusion_clause, get_audio_profile_languages, TableShows, TableEpisodes, TableMovies, \ from app.database import get_exclusion_clause, get_audio_profile_languages, TableShows, TableEpisodes, TableMovies, \
TableHistory, TableHistoryMovie TableHistory, TableHistoryMovie, get_profiles_list
from app.event_handler import show_progress, hide_progress from app.event_handler import show_progress, hide_progress
from app.get_providers import get_providers from app.get_providers import get_providers
from app.notifier import send_notifications, send_notifications_movie from app.notifier import send_notifications, send_notifications_movie
@ -217,7 +217,7 @@ def get_upgradable_episode_subtitles():
if not upgradable_episodes: if not upgradable_episodes:
return [] return []
else: else:
upgradable_episodes = list(upgradable_episodes) upgradable_episodes = [x for x in upgradable_episodes if _language_still_desired(x['language'], x['profileId'])]
logging.debug(f"{len(upgradable_episodes)} potentially upgradable episode subtitles have been found, let's " logging.debug(f"{len(upgradable_episodes)} potentially upgradable episode subtitles have been found, let's "
f"filter them...") f"filter them...")
@ -252,8 +252,32 @@ def get_upgradable_movies_subtitles():
if not upgradable_movies: if not upgradable_movies:
return [] return []
else: else:
upgradable_movies = list(upgradable_movies) upgradable_movies = [x for x in upgradable_movies if _language_still_desired(x['language'], x['profileId'])]
logging.debug(f"{len(upgradable_movies)} potentially upgradable movie subtitles have been found, let's filter " logging.debug(f"{len(upgradable_movies)} potentially upgradable movie subtitles have been found, let's filter "
f"them...") f"them...")
return parse_upgradable_list(upgradable_list=upgradable_movies, perfect_score=117, media_type='movie') return parse_upgradable_list(upgradable_list=upgradable_movies, perfect_score=117, media_type='movie')
def _language_still_desired(language, profile_id):
if not profile_id:
return False
profile = get_profiles_list(profile_id)
if profile and language in _language_from_items(profile['items']):
return True
else:
return False
def _language_from_items(items):
results = []
for item in items:
if item['forced'] == 'True':
results.append(item['language'] + ':forced')
elif item['hi'] == 'True':
results.append(item['language'] + ':hi')
else:
results.append(item['language'])
results.append(item['language'] + ':hi')
return results

Loading…
Cancel
Save