From 495b730b30c984b16e482e7b7a160f6bf3206ddd Mon Sep 17 00:00:00 2001 From: meisnate12 Date: Thu, 9 Dec 2021 10:23:51 -0500 Subject: [PATCH] fix for sonarr/radarr --- modules/builder.py | 8 ++++++-- modules/radarr.py | 4 +++- modules/sonarr.py | 4 +++- plex_meta_manager.py | 8 ++++++-- 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/modules/builder.py b/modules/builder.py index 08087f98..f0e11e49 100644 --- a/modules/builder.py +++ b/modules/builder.py @@ -1945,9 +1945,13 @@ class CollectionBuilder: self.library.edit_tags("label", item, add_tags=add_tags, remove_tags=remove_tags, sync_tags=sync_tags) path = os.path.dirname(str(item.locations[0])) if self.library.is_movie else str(item.locations[0]) if self.library.Radarr and item.ratingKey in self.library.movie_rating_key_map: - tmdb_paths.append((self.library.movie_rating_key_map[item.ratingKey], f"{path.replace(self.library.Radarr.plex_path, self.library.Radarr.radarr_path)}/")) + path = path.replace(self.library.Radarr.plex_path, self.library.Radarr.radarr_path) + path = path[:-1] if path.endswith(('/', '\\')) else path + tmdb_paths.append((self.library.movie_rating_key_map[item.ratingKey], path)) if self.library.Sonarr and item.ratingKey in self.library.show_rating_key_map: - tvdb_paths.append((self.library.show_rating_key_map[item.ratingKey], f"{path.replace(self.library.Sonarr.plex_path, self.library.Sonarr.sonarr_path)}/")) + path = path.replace(self.library.Sonarr.plex_path, self.library.Sonarr.sonarr_path) + path = path[:-1] if path.endswith(('/', '\\')) else path + tvdb_paths.append((self.library.show_rating_key_map[item.ratingKey], path)) advance_edits = {} for method_name, method_data in self.item_details.items(): if method_name in plex.item_advance_keys: diff --git a/modules/radarr.py b/modules/radarr.py index 2269ad9c..c6fb1a21 100644 --- a/modules/radarr.py +++ b/modules/radarr.py @@ -58,8 +58,10 @@ class Radarr: arr_ids = {} for movie in self.api.all_movies(): if movie.path: - arr_paths[movie.path] = movie.tmdbId + arr_paths[movie.path[:-1] if movie.path.endswith(("/", "\\")) else movie.path] = movie.tmdbId arr_ids[movie.tmdbId] = movie + logger.debug(arr_paths) + logger.debug(arr_ids) added = [] exists = [] diff --git a/modules/sonarr.py b/modules/sonarr.py index 0eefe4ce..00608643 100644 --- a/modules/sonarr.py +++ b/modules/sonarr.py @@ -84,8 +84,10 @@ class Sonarr: arr_ids = {} for series in self.api.all_series(): if series.path: - arr_paths[series.path] = series.tvdbId + arr_paths[series.path[:-1] if series.path.endswith(("/", "\\")) else series.path] = series.tvdbId arr_paths[series.tvdbId] = series + logger.debug(arr_paths) + logger.debug(arr_ids) added = [] exists = [] diff --git a/plex_meta_manager.py b/plex_meta_manager.py index cd43667c..101378d0 100644 --- a/plex_meta_manager.py +++ b/plex_meta_manager.py @@ -410,9 +410,13 @@ def library_operations(config, library): path = os.path.dirname(str(item.locations[0])) if library.is_movie else str(item.locations[0]) if library.Radarr and library.radarr_add_all and tmdb_id: - radarr_adds.append((tmdb_id, f"{path.replace(library.Radarr.plex_path, library.Radarr.radarr_path)}/")) + path = path.replace(library.Radarr.plex_path, library.Radarr.radarr_path) + path = path[:-1] if path.endswith(('/', '\\')) else path + radarr_adds.append((tmdb_id, path)) if library.Sonarr and library.sonarr_add_all and tvdb_id: - sonarr_adds.append((tvdb_id, f"{path.replace(library.Sonarr.plex_path, library.Sonarr.sonarr_path)}/")) + path = path.replace(library.Sonarr.plex_path, library.Sonarr.sonarr_path) + path = path[:-1] if path.endswith(('/', '\\')) else path + sonarr_adds.append((tvdb_id, path)) tmdb_item = None if library.tmdb_collections or library.mass_genre_update == "tmdb" or library.mass_audience_rating_update == "tmdb" or library.mass_critic_rating_update == "tmdb":