Added support for Radarr Aphrodite.

This commit is contained in:
Louis Vézina 2019-09-09 14:33:40 -04:00
parent 859bc90662
commit 3e20252434

View file

@ -8,6 +8,7 @@ from queueconfig import notifications
from get_args import args from get_args import args
from config import settings, url_radarr from config import settings, url_radarr
from helper import path_replace_movie from helper import path_replace_movie
from utils import get_radarr_version
from list_subtitles import store_subtitles_movie, list_missing_subtitles_movies, movies_full_scan_subtitles from list_subtitles import store_subtitles_movie, list_missing_subtitles_movies, movies_full_scan_subtitles
from get_subtitle import movies_download_subtitles from get_subtitle import movies_download_subtitles
@ -33,7 +34,7 @@ def update_movies():
if apikey_radarr is None: if apikey_radarr is None:
pass pass
else: else:
get_profile_list() audio_profiles = get_profile_list()
# Get movies data from radarr # Get movies data from radarr
url_radarr_api_movies = url_radarr + "/api/movie?apikey=" + apikey_radarr url_radarr_api_movies = url_radarr + "/api/movie?apikey=" + apikey_radarr
@ -140,7 +141,7 @@ def update_movies():
'tmdb_id': unicode(movie["tmdbId"]), 'tmdb_id': unicode(movie["tmdbId"]),
'poster': unicode(poster), 'poster': unicode(poster),
'fanart': unicode(fanart), 'fanart': unicode(fanart),
'audio_language': unicode(profile_id_to_language(movie['qualityProfileId'])), 'audio_language': unicode(profile_id_to_language(movie['qualityProfileId'], audio_profiles)),
'scene_name': sceneName, 'scene_name': sceneName,
'monitored': unicode(bool(movie['monitored'])), 'monitored': unicode(bool(movie['monitored'])),
'year': unicode(movie['year']), 'year': unicode(movie['year']),
@ -164,7 +165,7 @@ def update_movies():
'overview': overview, 'overview': overview,
'poster': poster, 'poster': poster,
'fanart': fanart, 'fanart': fanart,
'audio_language': profile_id_to_language(movie['qualityProfileId']), 'audio_language': profile_id_to_language(movie['qualityProfileId'], audio_profiles),
'scene_name': sceneName, 'scene_name': sceneName,
'monitored': unicode(bool(movie['monitored'])), 'monitored': unicode(bool(movie['monitored'])),
'sort_title': movie['sortTitle'], 'sort_title': movie['sortTitle'],
@ -184,7 +185,7 @@ def update_movies():
'overview': overview, 'overview': overview,
'poster': poster, 'poster': poster,
'fanart': fanart, 'fanart': fanart,
'audio_language': profile_id_to_language(movie['qualityProfileId']), 'audio_language': profile_id_to_language(movie['qualityProfileId'], audio_profiles),
'scene_name': sceneName, 'scene_name': sceneName,
'monitored': unicode(bool(movie['monitored'])), 'monitored': unicode(bool(movie['monitored'])),
'sort_title': movie['sortTitle'], 'sort_title': movie['sortTitle'],
@ -273,10 +274,9 @@ def update_movies():
def get_profile_list(): def get_profile_list():
apikey_radarr = settings.radarr.apikey apikey_radarr = settings.radarr.apikey
radarr_version = get_radarr_version()
# Get profiles data from radarr
global profiles_list
profiles_list = [] profiles_list = []
# Get profiles data from radarr
url_radarr_api_movies = url_radarr + "/api/profile?apikey=" + apikey_radarr url_radarr_api_movies = url_radarr + "/api/profile?apikey=" + apikey_radarr
try: try:
@ -289,12 +289,20 @@ def get_profile_list():
logging.exception("BAZARR Error trying to get profiles from Radarr.") logging.exception("BAZARR Error trying to get profiles from Radarr.")
else: else:
# Parsing data returned from radarr # Parsing data returned from radarr
if radarr_version.startswith('0'):
for profile in profiles_json.json(): for profile in profiles_json.json():
profiles_list.append([profile['id'], profile['language'].capitalize()]) profiles_list.append([profile['id'], profile['language'].capitalize()])
elif radarr_version.startswith('2'):
for profile in profiles_json.json():
profiles_list.append([profile['id'], profile['language']['name'].capitalize()])
return profiles_list
return None
def profile_id_to_language(id): def profile_id_to_language(id, profiles):
for profile in profiles_list: for profile in profiles:
if id == profile[0]: if id == profile[0]:
return profile[1] return profile[1]