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

This commit is contained in:
morpheus65535 2021-05-31 15:12:55 -04:00
parent e710488d7a
commit 3468601d4d
3 changed files with 24 additions and 9 deletions

View File

@ -44,7 +44,7 @@ def update_movies(send_event=True):
pass pass
else: else:
audio_profiles = get_profile_list() audio_profiles = get_profile_list()
tagsDict = get_tags() tagsDict = get_tags(radarr_version=radarr_version)
# Get movies data from radarr # Get movies data from radarr
movies = get_movies_from_radarr_api(radarr_version=radarr_version, url=url_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 movie_default_profile = None
audio_profiles = get_profile_list() audio_profiles = get_profile_list()
tagsDict = get_tags() tagsDict = get_tags(radarr_version=radarr_version)
try: try:
# Get movie data from radarr api # Get movie data from radarr api
@ -339,12 +339,15 @@ def RadarrFormatVideoCodec(videoFormat, videoCodecID, videoCodecLibrary):
return videoFormat return videoFormat
def get_tags(): def get_tags(radarr_version):
apikey_radarr = settings.radarr.apikey apikey_radarr = settings.radarr.apikey
tagsDict = [] tagsDict = []
# Get tags data from Radarr # 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: try:
tagsDict = requests.get(url_radarr_api_series, timeout=60, verify=False, headers=headers) tagsDict = requests.get(url_radarr_api_series, timeout=60, verify=False, headers=headers)

View File

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

View File

@ -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 check_update import apply_update, check_if_new_update, check_releases
from server import app, webserver from server import app, webserver
from functools import wraps from functools import wraps
from utils import check_credentials from utils import check_credentials, get_radarr_version
# Install downloaded update # Install downloaded update
if bazarr_version != '': if bazarr_version != '':
@ -145,7 +145,11 @@ def series_images(url):
def movies_images(url): def movies_images(url):
apikey = settings.radarr.apikey apikey = settings.radarr.apikey
baseUrl = settings.radarr.base_url 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: try:
req = requests.get(url_image, stream=True, timeout=15, verify=False, headers=headers) req = requests.get(url_image, stream=True, timeout=15, verify=False, headers=headers)
except: except: