From aebe78799f6d5c5fce1485013c5a24ab4881a726 Mon Sep 17 00:00:00 2001 From: meisnate12 Date: Mon, 6 Dec 2021 21:10:36 -0500 Subject: [PATCH] check arr paths for new IDs --- modules/radarr.py | 13 +++++++++++++ modules/sonarr.py | 14 +++++++++++++- requirements.txt | 2 +- 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/modules/radarr.py b/modules/radarr.py index 38e8f082..2269ad9c 100644 --- a/modules/radarr.py +++ b/modules/radarr.py @@ -19,6 +19,7 @@ class Radarr: try: self.api = RadarrAPI(self.url, self.token, session=self.config.session) self.api.respect_list_exclusions_when_adding() + self.api._validate_add_options(params["root_folder_path"], params["quality_profile"]) except ArrException as e: raise Failed(e) self.add = params["add"] @@ -67,6 +68,7 @@ class Radarr: movies = [] path_lookup = {} mismatched = {} + path_in_use = {} for i, item in enumerate(tmdb_ids, 1): path = item[1] if isinstance(item, tuple) else None tmdb_id = item[0] if isinstance(item, tuple) else item @@ -84,6 +86,9 @@ class Radarr: mismatched[path] = tmdb_id continue movie = self.api.get_movie(tmdb_id=tmdb_id) + if f"{folder}/{movie.folder}" in arr_paths: + path_in_use[f"{folder}/{movie.folder}"] = tmdb_id + continue if path: movies.append((movie, path)) path_lookup[path] = tmdb_id @@ -124,10 +129,18 @@ class Radarr: if len(mismatched) > 0: logger.info("") + logger.info("Items in Plex that have already been added to Radarr but under a different TMDb ID then in Plex") for path, tmdb_id in mismatched.items(): logger.info(f"Plex TMDb ID: {tmdb_id:<7} | Radarr TMDb ID: {arr_paths[path]:<7} | Path: {path}") logger.info(f"{len(mismatched)} Movie{'s' if len(mismatched) > 1 else ''} with mismatched TMDb IDs") + if len(path_in_use) > 0: + logger.info("") + logger.info("TMDb IDs that cannot be added to Radarr because the path they will use is already in use by a different TMDb ID") + for path, tmdb_id in path_in_use.items(): + logger.info(f"TMDb ID: {tmdb_id:<7} | Radarr TMDb ID: {arr_paths[path]:<7} | Path: {path}") + logger.info(f"{len(path_in_use)} Movie{'s' if len(path_in_use) > 1 else ''} with paths already in use by other TMDb IDs") + if len(invalid) > 0: logger.info("") for tmdb_id in invalid: diff --git a/modules/sonarr.py b/modules/sonarr.py index dc13ecee..0eefe4ce 100644 --- a/modules/sonarr.py +++ b/modules/sonarr.py @@ -37,6 +37,7 @@ class Sonarr: try: self.api = SonarrAPI(self.url, self.token, session=self.config.session) self.api.respect_list_exclusions_when_adding() + self.api._validate_add_options(params["root_folder_path"], params["quality_profile"], params["language_profile"]) except ArrException as e: raise Failed(e) self.add = params["add"] @@ -93,6 +94,7 @@ class Sonarr: shows = [] path_lookup = {} mismatched = {} + path_in_use = {} for i, item in enumerate(tvdb_ids, 1): path = item[1] if isinstance(item, tuple) else None tvdb_id = item[0] if isinstance(item, tuple) else item @@ -110,6 +112,9 @@ class Sonarr: mismatched[path] = tvdb_id continue show = self.api.get_series(tvdb_id=tvdb_id) + if f"{folder}/{show.folder}" in arr_paths: + path_in_use[f"{folder}/{show.folder}"] = tvdb_id + continue if path: shows.append((show, path)) path_lookup[path] = tvdb_id @@ -144,17 +149,24 @@ class Sonarr: if self.config.Cache: self.config.Cache.update_sonarr_adds(series.tvdbId, self.library.original_mapping_name) if len(skipped) > 0: - logger.info("") for series in skipped: logger.info(f"Skipped: In Cache | {series}") logger.info(f"{len(exists) + len(skipped)} Series already exist in Sonarr") if len(mismatched) > 0: logger.info("") + logger.info("Items in Plex that have already been added to Sonarr but under a different TVDb ID then in Plex") for path, tmdb_id in mismatched.items(): logger.info(f"Plex TVDb ID: {tmdb_id:<7} | Sonarr TVDb ID: {arr_paths[path]:<7} | Path: {path}") logger.info(f"{len(mismatched)} Series with mismatched TVDb IDs") + if len(path_in_use) > 0: + logger.info("") + logger.info("TVDb IDs that cannot be added to Sonarr because the path they will use is already in use by a different TVDb ID") + for path, tvdb_id in path_in_use.items(): + logger.info(f"TVDb ID: {tvdb_id:<7} | Sonarr TVDb ID: {arr_paths[path]:<7} | Path: {path}") + logger.info(f"{len(path_in_use)} Series with paths already in use by other TVDb IDs") + if len(invalid) > 0: for tvdb_id in invalid: logger.info("") diff --git a/requirements.txt b/requirements.txt index 61a6d685..2cb08b6f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,6 @@ PlexAPI==4.8.0 tmdbv3api==1.7.6 -arrapi==1.2.7 +arrapi==1.2.8 lxml==4.6.4 requests==2.26.0 ruamel.yaml==0.17.17