diff options
author | morpheus65535 <[email protected]> | 2021-05-31 15:12:55 -0400 |
---|---|---|
committer | morpheus65535 <[email protected]> | 2021-05-31 15:12:55 -0400 |
commit | 3468601d4d4b9078e76b7a5335da44ab19f97f1e (patch) | |
tree | 1222d0aab9071709abcce62fa7e9415aa344cf72 | |
parent | e710488d7a70d95993de05759fd625ddccd4482e (diff) | |
download | bazarr-3468601d4d4b9078e76b7a5335da44ab19f97f1e.tar.gz bazarr-3468601d4d4b9078e76b7a5335da44ab19f97f1e.zip |
Fixed API call to Radarr since the are removing legacy API from nightly builds.
-rw-r--r-- | bazarr/get_movies.py | 11 | ||||
-rw-r--r-- | bazarr/get_rootfolder.py | 14 | ||||
-rw-r--r-- | bazarr/main.py | 8 |
3 files changed, 24 insertions, 9 deletions
diff --git a/bazarr/get_movies.py b/bazarr/get_movies.py index 239839a42..bfb373070 100644 --- a/bazarr/get_movies.py +++ b/bazarr/get_movies.py @@ -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) diff --git a/bazarr/get_rootfolder.py b/bazarr/get_rootfolder.py index bda0a7356..c74b5c632 100644 --- a/bazarr/get_rootfolder.py +++ b/bazarr/get_rootfolder.py @@ -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']) \ diff --git a/bazarr/main.py b/bazarr/main.py index 7e49be42d..a364039ab 100644 --- a/bazarr/main.py +++ b/bazarr/main.py @@ -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: |