#620 Add List of T*Db IDs added to *arr to the collection payload

This commit is contained in:
meisnate12 2022-01-25 01:30:07 -05:00
parent bc6a6254be
commit db9b08a5c3
4 changed files with 22 additions and 7 deletions

View file

@ -216,6 +216,8 @@ class CollectionBuilder:
self.missing_movies = [] self.missing_movies = []
self.missing_shows = [] self.missing_shows = []
self.missing_parts = [] self.missing_parts = []
self.added_to_radarr = []
self.added_to_sonarr = []
self.builders = [] self.builders = []
self.filters = [] self.filters = []
self.tmdb_filters = [] self.tmdb_filters = []
@ -1976,7 +1978,9 @@ class CollectionBuilder:
if self.library.Radarr: if self.library.Radarr:
if self.radarr_details["add_missing"]: if self.radarr_details["add_missing"]:
try: 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: except Failed as e:
logger.error(e) logger.error(e)
if "item_radarr_tag" in self.item_details: if "item_radarr_tag" in self.item_details:
@ -2015,7 +2019,9 @@ class CollectionBuilder:
if self.library.Sonarr: if self.library.Sonarr:
if self.sonarr_details["add_missing"]: if self.sonarr_details["add_missing"]:
try: 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: except Failed as e:
logger.error(e) logger.error(e)
if "item_sonarr_tag" in self.item_details: if "item_sonarr_tag" in self.item_details:
@ -2142,13 +2148,15 @@ class CollectionBuilder:
if "item_radarr_tag" in self.item_details: 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"]) 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"]: 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 self.library.Sonarr and tvdb_paths:
if "item_sonarr_tag" in self.item_details: 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"]) 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"]: 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: for rating_key in rating_keys:
try: try:
@ -2426,6 +2434,8 @@ class CollectionBuilder:
deleted=self.deleted, deleted=self.deleted,
additions=self.notification_additions, additions=self.notification_additions,
removals=self.notification_removals, removals=self.notification_removals,
radarr=self.added_to_radarr,
sonarr=self.added_to_sonarr,
playlist=playlist playlist=playlist
) )
except Failed as e: except Failed as e:
@ -2439,6 +2449,8 @@ class CollectionBuilder:
rating_keys = [] rating_keys = []
amount_added = 0 amount_added = 0
self.notification_additions = [] self.notification_additions = []
self.added_to_radarr = []
self.added_to_sonarr = []
for mm in self.run_again_movies: for mm in self.run_again_movies:
if mm in self.library.movie_map: if mm in self.library.movie_map:
rating_keys.extend(self.library.movie_map[mm]) rating_keys.extend(self.library.movie_map[mm])

View file

@ -170,7 +170,7 @@ class Radarr:
logger.info(f"Invalid Root Folder for TMDb ID | {tmdb_id:<7} | {path}") 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") 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): def edit_tags(self, tmdb_ids, tags, apply_tags):
logger.info("") logger.info("")

View file

@ -196,7 +196,7 @@ class Sonarr:
logger.info(f"Invalid Root Folder for TVDb ID | {tvdb_id:<7} | {path}") logger.info(f"Invalid Root Folder for TVDb ID | {tvdb_id:<7} | {path}")
logger.info(f"{len(invalid_root)} Series with Invalid Paths") logger.info(f"{len(invalid_root)} Series with Invalid Paths")
return len(added) return added
def edit_tags(self, tvdb_ids, tags, apply_tags): def edit_tags(self, tvdb_ids, tags, apply_tags):
logger.info("") logger.info("")

View file

@ -73,7 +73,8 @@ class Webhooks:
if playlist: json["playlist"] = str(playlist) if playlist: json["playlist"] = str(playlist)
self._request(self.error_webhooks, json) 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: if self.library:
thumb = None thumb = None
if not poster_url and collection.thumb and next((f for f in collection.fields if f.name == "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, "background_url": background_url,
"additions": additions if additions else [], "additions": additions if additions else [],
"removals": removals if removals else [], "removals": removals if removals else [],
"radarr_adds": radarr if radarr else [],
"sonarr_adds": sonarr if sonarr else [],
}) })