From 3c48c530066fcfb30071e9b7a6999414783650ee Mon Sep 17 00:00:00 2001 From: l3uddz Date: Mon, 12 Mar 2018 15:16:54 +0000 Subject: [PATCH] support multiple tags per show. show tag names in log messages instead of tag id's. --- misc/helpers.py | 18 +++++++++++++++++- traktarr.py | 5 +++-- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/misc/helpers.py b/misc/helpers.py index d235297..4045f22 100644 --- a/misc/helpers.py +++ b/misc/helpers.py @@ -10,16 +10,32 @@ log = logger.get_logger(__name__) def sonarr_series_tag_id_from_network(profile_tags, network_tags, network): try: + tags = [] for tag_name, tag_networks in network_tags.items(): for tag_network in tag_networks: if tag_network.lower() in network.lower() and tag_name.lower() in profile_tags: log.debug("Using %s tag for network: %s", tag_name, network) - return [profile_tags[tag_name.lower()]] + tags.append(profile_tags[tag_name.lower()]) + if tags: + return tags except Exception: log.exception("Exception determining tag to use for network %s: ", network) return None +def sonarr_readable_tag_from_ids(profile_tag_ids, chosen_tag_ids): + try: + tags = [] + for tag_name, tag_id in profile_tag_ids.items(): + if tag_id in chosen_tag_ids: + tags.append(tag_name) + if tags: + return tags + except Exception: + log.exception("Exception building readable tag name list from ids %s: ", chosen_tag_ids) + return None + + def sonarr_series_to_tvdb_dict(sonarr_series): series = {} try: diff --git a/traktarr.py b/traktarr.py index 35cf2ef..27dc4f9 100644 --- a/traktarr.py +++ b/traktarr.py @@ -157,13 +157,14 @@ def shows(list_type, add_limit=0, add_delay=2.5, no_search=False, notifications= if sonarr.add_series(series['show']['ids']['tvdb'], series['show']['title'], series['show']['ids']['slug'], profile_id, cfg.sonarr.root_folder, use_tags, not no_search): - log.info("ADDED %s (%d) with tags: %s", series['show']['title'], series['show']['year'], use_tags) + log.info("ADDED %s (%d) with tags: %s", series['show']['title'], series['show']['year'], + helpers.sonarr_readable_tag_from_ids(profile_tags, use_tags)) if notifications: callback_notify({'event': 'add_show', 'list_type': list_type, 'show': series['show']}) added_shows += 1 else: log.error("FAILED adding %s (%d) with tags: %s", series['show']['title'], series['show']['year'], - use_tags) + helpers.sonarr_readable_tag_from_ids(profile_tags, use_tags)) # stop adding shows, if added_shows >= add_limit if add_limit and added_shows >= add_limit: