Fixed API call to Radarr since the are removing legacy API from nightly builds.

pull/1427/head
morpheus65535 4 years ago
parent e710488d7a
commit 3468601d4d

@ -44,7 +44,7 @@ def update_movies(send_event=True):
pass
else:
audio_profiles = get_profile_list()
tagsDict = get_tags()
tagsDict = get_tags(radarr_version=radarr_version)
# Get movies data from radarr
movies = get_movies_from_radarr_api(radarr_version=radarr_version, url=url_radarr(),
@ -194,7 +194,7 @@ def update_one_movie(movie_id, action):
movie_default_profile = None
audio_profiles = get_profile_list()
tagsDict = get_tags()
tagsDict = get_tags(radarr_version=radarr_version)
try:
# Get movie data from radarr api
@ -339,12 +339,15 @@ def RadarrFormatVideoCodec(videoFormat, videoCodecID, videoCodecLibrary):
return videoFormat
def get_tags():
def get_tags(radarr_version):
apikey_radarr = settings.radarr.apikey
tagsDict = []
# Get tags data from Radarr
url_radarr_api_series = url_radarr() + "/api/tag?apikey=" + apikey_radarr
if radarr_version.startswith('0'):
url_radarr_api_series = url_radarr() + "/api/tag?apikey=" + apikey_radarr
else:
url_radarr_api_series = url_radarr() + "/api/v3/tag?apikey=" + apikey_radarr
try:
tagsDict = requests.get(url_radarr_api_series, timeout=60, verify=False, headers=headers)

@ -7,6 +7,7 @@ import logging
from config import settings, url_sonarr, url_radarr
from helper import path_mappings
from database import TableShowsRootfolder, TableMoviesRootfolder, TableShows, TableMovies
from utils import get_radarr_version
headers = {"User-Agent": os.environ["SZ_USER_AGENT"]}
@ -79,9 +80,13 @@ def check_sonarr_rootfolder():
def get_radarr_rootfolder():
apikey_radarr = settings.radarr.apikey
radarr_rootfolder = []
radarr_version = get_radarr_version()
# Get root folder data from Radarr
url_radarr_api_rootfolder = url_radarr() + "/api/rootfolder?apikey=" + apikey_radarr
if radarr_version.startswith('0'):
url_radarr_api_rootfolder = url_radarr() + "/api/rootfolder?apikey=" + apikey_radarr
else:
url_radarr_api_rootfolder = url_radarr() + "/api/v3/rootfolder?apikey=" + apikey_radarr
try:
rootfolder = requests.get(url_radarr_api_rootfolder, timeout=60, verify=False, headers=headers)
@ -121,14 +126,17 @@ def check_radarr_rootfolder():
get_radarr_rootfolder()
rootfolder = TableMoviesRootfolder.select(TableMoviesRootfolder.id, TableMoviesRootfolder.path).dicts()
for item in rootfolder:
if not os.path.isdir(path_mappings.path_replace_movie(item['path'])):
root_path = item['path']
if not root_path.endswith(os.path.sep):
root_path += os.path.sep
if not os.path.isdir(path_mappings.path_replace_movie(root_path)):
TableMoviesRootfolder.update({TableMoviesRootfolder.accessible: 0,
TableMoviesRootfolder.error: 'This Radarr root directory does not seems to '
'be accessible by Bazarr. Please check path '
'mapping.'}) \
.where(TableMoviesRootfolder.id == item['id']) \
.execute()
elif not os.access(path_mappings.path_replace_movie(item['path']), os.W_OK):
elif not os.access(path_mappings.path_replace_movie(root_path), os.W_OK):
TableMoviesRootfolder.update({TableMoviesRootfolder.accessible: 0,
TableMoviesRootfolder.error: 'Bazarr cannot write to this directory'}) \
.where(TableMoviesRootfolder.id == item['id']) \

@ -43,7 +43,7 @@ from signalr_client import sonarr_signalr_client, radarr_signalr_client
from check_update import apply_update, check_if_new_update, check_releases
from server import app, webserver
from functools import wraps
from utils import check_credentials
from utils import check_credentials, get_radarr_version
# Install downloaded update
if bazarr_version != '':
@ -145,7 +145,11 @@ def series_images(url):
def movies_images(url):
apikey = settings.radarr.apikey
baseUrl = settings.radarr.base_url
url_image = url_radarr() + '/api/' + url.lstrip(baseUrl) + '?apikey=' + apikey
radarr_version = get_radarr_version()
if radarr_version.startswith('0'):
url_image = url_radarr() + '/api/' + url.lstrip(baseUrl) + '?apikey=' + apikey
else:
url_image = url_radarr() + '/api/v3/' + url.lstrip(baseUrl) + '?apikey=' + apikey
try:
req = requests.get(url_image, stream=True, timeout=15, verify=False, headers=headers)
except:

Loading…
Cancel
Save