From db9b08a5c36085c2199da7e74876167104f4eb46 Mon Sep 17 00:00:00 2001 From: meisnate12 Date: Tue, 25 Jan 2022 01:30:07 -0500 Subject: [PATCH] #620 Add List of T*Db IDs added to *arr to the collection payload --- modules/builder.py | 20 ++++++++++++++++---- modules/radarr.py | 2 +- modules/sonarr.py | 2 +- modules/webhooks.py | 5 ++++- 4 files changed, 22 insertions(+), 7 deletions(-) diff --git a/modules/builder.py b/modules/builder.py index f72bd25c..0c24440b 100644 --- a/modules/builder.py +++ b/modules/builder.py @@ -216,6 +216,8 @@ class CollectionBuilder: self.missing_movies = [] self.missing_shows = [] self.missing_parts = [] + self.added_to_radarr = [] + self.added_to_sonarr = [] self.builders = [] self.filters = [] self.tmdb_filters = [] @@ -1976,7 +1978,9 @@ class CollectionBuilder: if self.library.Radarr: if self.radarr_details["add_missing"]: try: - added_to_radarr += self.library.Radarr.add_tmdb(missing_tmdb_ids, **self.radarr_details) + added = self.library.Radarr.add_tmdb(missing_tmdb_ids, **self.radarr_details) + self.added_to_radarr.extend([movie.tmdbId for movie in added]) + added_to_radarr += len(added) except Failed as e: logger.error(e) if "item_radarr_tag" in self.item_details: @@ -2015,7 +2019,9 @@ class CollectionBuilder: if self.library.Sonarr: if self.sonarr_details["add_missing"]: try: - added_to_sonarr += self.library.Sonarr.add_tvdb(missing_tvdb_ids, **self.sonarr_details) + added = self.library.Sonarr.add_tvdb(missing_tvdb_ids, **self.sonarr_details) + self.added_to_sonarr.extend([show.tvdbId for show in added]) + added_to_sonarr += len(added) except Failed as e: logger.error(e) if "item_sonarr_tag" in self.item_details: @@ -2142,13 +2148,15 @@ class CollectionBuilder: if "item_radarr_tag" in self.item_details: self.library.Radarr.edit_tags([t[0] if isinstance(t, tuple) else t for t in tmdb_paths], self.item_details["item_radarr_tag"], self.item_details["apply_tags"]) if self.radarr_details["add_existing"]: - self.library.Radarr.add_tmdb(tmdb_paths, **self.radarr_details) + added = self.library.Radarr.add_tmdb(tmdb_paths, **self.radarr_details) + self.added_to_radarr.extend([movie.tmdbId for movie in added]) if self.library.Sonarr and tvdb_paths: if "item_sonarr_tag" in self.item_details: self.library.Sonarr.edit_tags([t[0] if isinstance(t, tuple) else t for t in tvdb_paths], self.item_details["item_sonarr_tag"], self.item_details["apply_tags"]) if self.sonarr_details["add_existing"]: - self.library.Sonarr.add_tvdb(tvdb_paths, **self.sonarr_details) + added = self.library.Sonarr.add_tvdb(tvdb_paths, **self.sonarr_details) + self.added_to_sonarr.extend([show.tvdbId for show in added]) for rating_key in rating_keys: try: @@ -2426,6 +2434,8 @@ class CollectionBuilder: deleted=self.deleted, additions=self.notification_additions, removals=self.notification_removals, + radarr=self.added_to_radarr, + sonarr=self.added_to_sonarr, playlist=playlist ) except Failed as e: @@ -2439,6 +2449,8 @@ class CollectionBuilder: rating_keys = [] amount_added = 0 self.notification_additions = [] + self.added_to_radarr = [] + self.added_to_sonarr = [] for mm in self.run_again_movies: if mm in self.library.movie_map: rating_keys.extend(self.library.movie_map[mm]) diff --git a/modules/radarr.py b/modules/radarr.py index b026f424..940fc37e 100644 --- a/modules/radarr.py +++ b/modules/radarr.py @@ -170,7 +170,7 @@ class Radarr: logger.info(f"Invalid Root Folder for TMDb ID | {tmdb_id:<7} | {path}") logger.info(f"{len(invalid_root)} Movie{'s' if len(invalid_root) > 1 else ''} with Invalid Paths") - return len(added) + return added def edit_tags(self, tmdb_ids, tags, apply_tags): logger.info("") diff --git a/modules/sonarr.py b/modules/sonarr.py index 2e8e1c75..a959cdb2 100644 --- a/modules/sonarr.py +++ b/modules/sonarr.py @@ -196,7 +196,7 @@ class Sonarr: logger.info(f"Invalid Root Folder for TVDb ID | {tvdb_id:<7} | {path}") logger.info(f"{len(invalid_root)} Series with Invalid Paths") - return len(added) + return added def edit_tags(self, tvdb_ids, tags, apply_tags): logger.info("") diff --git a/modules/webhooks.py b/modules/webhooks.py index ace4602c..a9e7b9df 100644 --- a/modules/webhooks.py +++ b/modules/webhooks.py @@ -73,7 +73,8 @@ class Webhooks: if playlist: json["playlist"] = str(playlist) self._request(self.error_webhooks, json) - def collection_hooks(self, webhooks, collection, poster_url=None, background_url=None, created=False, deleted=False, additions=None, removals=None, playlist=False): + def collection_hooks(self, webhooks, collection, poster_url=None, background_url=None, created=False, deleted=False, + additions=None, removals=None, radarr=None, sonarr=None, playlist=False): if self.library: thumb = None if not poster_url and collection.thumb and next((f for f in collection.fields if f.name == "thumb"), None): @@ -93,4 +94,6 @@ class Webhooks: "background_url": background_url, "additions": additions if additions else [], "removals": removals if removals else [], + "radarr_adds": radarr if radarr else [], + "sonarr_adds": sonarr if sonarr else [], })